-
-
Notifications
You must be signed in to change notification settings - Fork 499
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(drivers): introduce platforms, move DriverConfig values there
- Loading branch information
Showing
20 changed files
with
97 additions
and
67 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
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,8 +1,10 @@ | ||
import { MySqlConnection } from '../connections/MySqlConnection'; | ||
import { AbstractSqlDriver } from './AbstractSqlDriver'; | ||
import { MySqPlatform } from '../platforms/MySqPlatform'; | ||
|
||
export class MySqlDriver extends AbstractSqlDriver<MySqlConnection> { | ||
|
||
protected readonly connection = new MySqlConnection(this.config); | ||
protected readonly platform = new MySqPlatform(); | ||
|
||
} |
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,10 @@ | ||
import { UnderscoreNamingStrategy } from '../naming-strategy'; | ||
import { SqliteConnection } from '../connections/SqliteConnection'; | ||
import { AbstractSqlDriver } from './AbstractSqlDriver'; | ||
import { DriverConfig } from './IDatabaseDriver'; | ||
import { SqlitePlatform } from '../platforms/SqlitePlatform'; | ||
|
||
export class SqliteDriver extends AbstractSqlDriver<SqliteConnection> { | ||
|
||
protected readonly connection = new SqliteConnection(this.config); | ||
|
||
getConfig(): DriverConfig { | ||
return { | ||
usesPivotTable: true, | ||
supportsTransactions: true, | ||
supportsSavePoints: true, | ||
namingStrategy: UnderscoreNamingStrategy, | ||
identifierQuoteCharacter: '"', | ||
}; | ||
} | ||
protected readonly platform = new SqlitePlatform(); | ||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { Platform } from './Platform'; | ||
import { MongoNamingStrategy, NamingStrategy } from '../naming-strategy'; | ||
|
||
export class MongoPlatform extends Platform { | ||
|
||
usesPivotTable(): boolean { | ||
return false; | ||
} | ||
|
||
supportsTransactions(): boolean { | ||
return false; | ||
} | ||
|
||
getNamingStrategy(): { new(): NamingStrategy} { | ||
return MongoNamingStrategy; | ||
} | ||
|
||
} |
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { Platform } from './Platform'; | ||
|
||
export class MySqPlatform extends Platform { | ||
|
||
getIdentifierQuoteCharacter(): string { | ||
return '`'; | ||
} | ||
|
||
} |
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { NamingStrategy, UnderscoreNamingStrategy } from '../naming-strategy'; | ||
|
||
export abstract class Platform { | ||
|
||
usesPivotTable(): boolean { | ||
return true; | ||
} | ||
|
||
supportsTransactions(): boolean { | ||
return true; | ||
} | ||
|
||
supportsSavePoints(): boolean { | ||
return false; | ||
} | ||
|
||
getNamingStrategy(): { new(): NamingStrategy} { | ||
return UnderscoreNamingStrategy; | ||
} | ||
|
||
getIdentifierQuoteCharacter(): string { | ||
return '"'; | ||
} | ||
|
||
} |
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { Platform } from './Platform'; | ||
|
||
export class SqlitePlatform extends Platform { | ||
|
||
supportsSavePoints(): boolean { | ||
return true; | ||
} | ||
|
||
} |
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