Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for better-sqlite3 driver #505

Closed
michaelbromley opened this issue Oct 15, 2020 · 0 comments
Closed

Add support for better-sqlite3 driver #505

michaelbromley opened this issue Oct 15, 2020 · 0 comments

Comments

@michaelbromley
Copy link
Member

Is your feature request related to a problem? Please describe.
It appears that using the sqlite3 package leads to concurrency issues when creating products in the Admin UI. Creating a product with more than 1 variant when using the sqlite driver in the TypeORM connection options results in:

"Transaction already started for the given connection, commit current transaction before starting a new one."

This issue is explored here: typeorm/typeorm#1884

Describe the solution you'd like
I tried switching over to the better-sqlite3 package (support for this was added in TypeORM 0.2.26) and the issue goes away.

The problem is that currently the DefaultSearchPlugin will fail because it does not recognise the 'better-sqlite3' type:

private setSearchStrategy() {
switch (this.connection.rawConnection.options.type) {
case 'mysql':
case 'mariadb':
this.searchStrategy = new MysqlSearchStrategy(this.connection);
break;
case 'sqlite':
case 'sqljs':
this.searchStrategy = new SqliteSearchStrategy(this.connection);
break;
case 'postgres':
this.searchStrategy = new PostgresSearchStrategy(this.connection);
break;
default:
throw new InternalServerError(`error.database-not-supported-by-default-search-plugin`);
}
}

The solution is to:

  1. Add better-sqlite3 to the above switch statement.
  2. Use better-sqlite3 by default in @vendure/create
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant