mirror of
https://github.com/typeorm/typeorm.git
synced 2025-12-08 21:26:23 +00:00
Merge pull request #3190 from saboya/sqlite-on-conflict
Add flag to enable ON CONFLICT support for Sqlite.
This commit is contained in:
commit
efb6353fdc
@ -18,6 +18,7 @@ before_script:
|
||||
- sudo service postgresql stop
|
||||
- docker-compose up -d
|
||||
- cp ormconfig.travis.json ormconfig.json
|
||||
- npm install sqlite3 --build-from-source
|
||||
|
||||
script:
|
||||
- npm test
|
||||
|
||||
@ -16,6 +16,7 @@ import {SqljsDriver} from "../driver/sqljs/SqljsDriver";
|
||||
import {BroadcasterResult} from "../subscriber/BroadcasterResult";
|
||||
import {EntitySchema} from "../";
|
||||
import {OracleDriver} from "../driver/oracle/OracleDriver";
|
||||
import {SqliteDriver} from "../driver/sqlite/SqliteDriver";
|
||||
|
||||
/**
|
||||
* Allows to build complex sql queries in a fashion way and execute those queries.
|
||||
@ -299,7 +300,7 @@ export class InsertQueryBuilder<Entity> extends QueryBuilder<Entity> {
|
||||
query += ` DEFAULT VALUES`;
|
||||
}
|
||||
}
|
||||
if (this.connection.driver instanceof PostgresDriver) {
|
||||
if (this.connection.driver instanceof PostgresDriver || (this.connection.driver instanceof SqliteDriver)) {
|
||||
query += `${this.expressionMap.onIgnore ? " ON CONFLICT DO NOTHING " : ""}`;
|
||||
query += `${this.expressionMap.onConflict ? " ON CONFLICT " + this.expressionMap.onConflict : ""}`;
|
||||
if (this.expressionMap.onUpdate) {
|
||||
|
||||
@ -4,11 +4,11 @@ import {Connection} from "../../../../src/connection/Connection";
|
||||
import {Post} from "./entity/Post";
|
||||
|
||||
describe("query builder > insertion > on conflict", () => {
|
||||
|
||||
|
||||
let connections: Connection[];
|
||||
before(async () => connections = await createTestingConnections({
|
||||
entities: [__dirname + "/entity/*{.js,.ts}"],
|
||||
enabledDrivers: ["postgres"] // since on conflict statement is only supported in postgres
|
||||
enabledDrivers: ["postgres", "sqlite"] // since on conflict statement is only supported in postgres and sqlite >= 3.24.0
|
||||
}));
|
||||
beforeEach(() => reloadTestingDatabases(connections));
|
||||
after(() => closeTestingConnections(connections));
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user