-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(migrations): add support for migrations (closes #38)
- Loading branch information
1 parent
65402d3
commit b3ddb2b
Showing
70 changed files
with
1,304 additions
and
760 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...lient/src/querier/baseClientRepository.ts → ...nt/src/querier/genericClientRepository.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
export * from './httpQuerier'; | ||
export * from './baseClientRepository'; | ||
export * from './genericClientRepository'; | ||
export * from './querier.util'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
export * from './baseSqlDialect'; | ||
export * from './abstractSqlDialect'; | ||
export * from './mysqlDialect'; | ||
export * from './postgresDialect'; | ||
export * from './sqliteDialect'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,11 @@ | ||
import { createSpec, Item, User } from '@uql/core/test'; | ||
import { BaseSqlDialectSpec } from './baseSqlDialect-spec'; | ||
import { createSpec } from '@uql/core/test'; | ||
import { AbstractSqlDialectSpec } from './abstractSqlDialect-spec'; | ||
import { MySqlDialect } from './mysqlDialect'; | ||
|
||
export class MySqlDialectSpec extends BaseSqlDialectSpec { | ||
export class MySqlDialectSpec extends AbstractSqlDialectSpec { | ||
constructor() { | ||
super(new MySqlDialect()); | ||
} | ||
|
||
override shouldBeginTransaction() { | ||
expect(this.dialect.beginTransactionCommand).toBe('START TRANSACTION'); | ||
} | ||
|
||
override shouldFind$text() { | ||
expect( | ||
this.dialect.find(Item, { | ||
$project: ['id'], | ||
$filter: { $text: { $fields: ['name', 'description'], $value: 'some text' }, creatorId: 1 }, | ||
$limit: 30, | ||
}) | ||
).toBe("SELECT `id` FROM `Item` WHERE MATCH(`name`, `description`) AGAINST('some text') AND `creatorId` = 1 LIMIT 30"); | ||
|
||
expect( | ||
this.dialect.find(User, { | ||
$project: { id: true }, | ||
$filter: { | ||
$text: { $fields: ['name'], $value: 'something' }, | ||
name: { $ne: 'other unwanted' }, | ||
creatorId: 1, | ||
}, | ||
$limit: 10, | ||
}) | ||
).toBe("SELECT `id` FROM `User` WHERE MATCH(`name`) AGAINST('something') AND `name` <> 'other unwanted' AND `creatorId` = 1 LIMIT 10"); | ||
} | ||
} | ||
|
||
createSpec(new MySqlDialectSpec()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,7 @@ | ||
import { getMeta } from '@uql/core/entity'; | ||
import { QueryComparisonOptions, QueryFilterMap, QueryTextSearchOptions, Type } from '@uql/core/type'; | ||
import { BaseSqlDialect } from './baseSqlDialect'; | ||
import { AbstractSqlDialect } from './abstractSqlDialect'; | ||
|
||
export class MySqlDialect extends BaseSqlDialect { | ||
export class MySqlDialect extends AbstractSqlDialect { | ||
constructor() { | ||
super('START TRANSACTION', '`'); | ||
} | ||
|
||
override compare<E, K extends keyof QueryFilterMap<E>>(entity: Type<E>, key: K, val: QueryFilterMap<E>[K], opts?: QueryComparisonOptions): string { | ||
if (key === '$text') { | ||
const meta = getMeta(entity); | ||
const search = val as QueryTextSearchOptions<E>; | ||
const fields = search.$fields.map((field) => this.escapeId(meta.fields[field]?.name ?? field)); | ||
return `MATCH(${fields.join(', ')}) AGAINST(${this.escape(search.$value)})`; | ||
} | ||
|
||
return super.compare(entity, key, val, opts); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,37 @@ | ||
import { createSpec } from '@uql/core/test'; | ||
import { BaseSqlDialectSpec } from './baseSqlDialect-spec'; | ||
import { createSpec, Item, User } from '@uql/core/test'; | ||
import { AbstractSqlDialectSpec } from './abstractSqlDialect-spec'; | ||
import { SqliteDialect } from './sqliteDialect'; | ||
|
||
class SqliteDialectSpec extends BaseSqlDialectSpec { | ||
class SqliteDialectSpec extends AbstractSqlDialectSpec { | ||
constructor() { | ||
super(new SqliteDialect()); | ||
} | ||
|
||
override shouldBeginTransaction() { | ||
expect(this.dialect.beginTransactionCommand).toBe('BEGIN TRANSACTION'); | ||
} | ||
|
||
override shouldFind$text() { | ||
expect( | ||
this.dialect.find(Item, { | ||
$project: { id: true }, | ||
$filter: { $text: { $fields: ['name', 'description'], $value: 'some text' }, companyId: 1 }, | ||
$limit: 30, | ||
}) | ||
).toBe("SELECT `id` FROM `Item` WHERE `Item` MATCH 'some text' AND `companyId` = 1 LIMIT 30"); | ||
|
||
expect( | ||
this.dialect.find(User, { | ||
$project: { id: 1 }, | ||
$filter: { | ||
$text: { $fields: ['name'], $value: 'something' }, | ||
name: { $ne: 'other unwanted' }, | ||
companyId: 1, | ||
}, | ||
$limit: 10, | ||
}) | ||
).toBe("SELECT `id` FROM `User` WHERE `User` MATCH 'something' AND `name` <> 'other unwanted' AND `companyId` = 1 LIMIT 10"); | ||
} | ||
} | ||
|
||
createSpec(new SqliteDialectSpec()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,18 @@ | ||
import { BaseSqlDialect } from './baseSqlDialect'; | ||
import { getMeta } from '../entity'; | ||
import { QueryComparisonOptions, QueryFilterMap, QueryTextSearchOptions, Type } from '../type'; | ||
import { AbstractSqlDialect } from './abstractSqlDialect'; | ||
|
||
export class SqliteDialect extends BaseSqlDialect { | ||
export class SqliteDialect extends AbstractSqlDialect { | ||
constructor() { | ||
super('BEGIN TRANSACTION', '`'); | ||
} | ||
|
||
override compare<E, K extends keyof QueryFilterMap<E>>(entity: Type<E>, key: K, val: QueryFilterMap<E>[K], opts?: QueryComparisonOptions): string { | ||
if (key === '$text') { | ||
const meta = getMeta(entity); | ||
const search = val as QueryTextSearchOptions<E>; | ||
return `${this.escapeId(meta.name)} MATCH ${this.escape(search.$value)}`; | ||
} | ||
return super.compare(entity, key, val, opts); | ||
} | ||
} |
Oops, something went wrong.