Skip to content

Commit

Permalink
fix(database): Prevent usage of LIMIT in session storage driver when …
Browse files Browse the repository at this point in the history
…db backend is mysql/mariadb

Related to freshgiammi-lab/connect-typeorm#8

Closes #128
  • Loading branch information
FoxxMD committed Nov 29, 2022
1 parent fde2836 commit ef372e5
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/Web/Client/StorageProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {Logger} from "winston";
import {WebSetting} from "../../Common/WebEntities/WebSetting";
import {ErrorWithCause} from "pony-cause";
import {createCacheManager} from "../../Common/Cache";
import {MysqlDriver} from "typeorm/driver/mysql/MysqlDriver";

export interface CacheManagerStoreOptions {
prefix?: string
Expand Down Expand Up @@ -103,7 +104,12 @@ export class DatabaseStorageProvider extends StorageProvider {
}

createSessionStore(options?: TypeormStoreOptions): Store {
return new TypeormStore(options).connect(this.clientSessionRepo)
// https://github.com/freshgiammi-lab/connect-typeorm#implement-the-session-entity
// https://github.com/freshgiammi-lab/connect-typeorm/issues/8
// usage of LIMIT in subquery is not supported by mariadb/mysql
// limitSubquery: false -- turns off LIMIT usage
const realOptions = this.database.driver instanceof MysqlDriver ? {...options, limitSubquery: false} : options;
return new TypeormStore(realOptions).connect(this.clientSessionRepo)
}

async getSessionSecret(): Promise<string | undefined> {
Expand Down

0 comments on commit ef372e5

Please sign in to comment.