Skip to content

Commit

Permalink
added mariadb driver
Browse files Browse the repository at this point in the history
  • Loading branch information
Umed Khudoiberdiev committed Aug 29, 2016
1 parent 3180d13 commit 7fc08ac
Show file tree
Hide file tree
Showing 21 changed files with 1,025 additions and 41 deletions.
14 changes: 14 additions & 0 deletions config/parameters.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,20 @@
"password": "admin",
"database": "test2"
},
"mariadb": {
"host": "192.168.99.100",
"port": 3307,
"username": "root",
"password": "admin",
"database": "test"
},
"mariadbSecondary": {
"host": "192.168.99.100",
"port": 3307,
"username": "root",
"password": "admin",
"database": "test2"
},
"postgres": {
"host": "192.168.99.100",
"port": 5432,
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"gulp-tslint": "^6.0.2",
"gulp-typescript": "^2.13.6",
"gulpclass": "0.1.1",
"mariasql": "^0.2.6",
"mocha": "^3.0.1",
"mysql": "^2.11.1",
"pg": "^6.0.3",
Expand Down
3 changes: 3 additions & 0 deletions src/connection/ConnectionManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {MissingDriverError} from "./error/MissingDriverError";
import {PostgresDriver} from "../driver/postgres/PostgresDriver";
import {AlreadyHasActiveConnectionError} from "./error/AlreadyHasActiveConnectionError";
import {Logger} from "../logger/Logger";
import {MariaDbDriver} from "../driver/mariadb/MariaDbDriver";

/**
* Connection manager holds all connections made to the databases and providers helper management functions
Expand Down Expand Up @@ -117,6 +118,8 @@ export class ConnectionManager {
return new MysqlDriver(options, logger);
case "postgres":
return new PostgresDriver(options, logger);
case "mariadb":
return new MariaDbDriver(options, logger);
default:
throw new MissingDriverError(options.type);
}
Expand Down
9 changes: 8 additions & 1 deletion src/driver/Driver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {DriverOptions} from "./DriverOptions";
import {QueryRunner} from "./QueryRunner";
import {ColumnMetadata} from "../metadata/ColumnMetadata";
import {ObjectLiteral} from "../common/ObjectLiteral";
import {ColumnType} from "../metadata/types/ColumnTypes";

/**
* Driver organizes TypeORM communication with specific database management system.
Expand Down Expand Up @@ -62,8 +63,14 @@ export interface Driver {
preparePersistentValue(value: any, column: ColumnMetadata): any;

/**
* Prepares given value to a value to be hydrated, based on its column type and metadata.
* Prepares given value to a value to be persisted, based on its column metadata.
*/
prepareHydratedValue(value: any, type: ColumnType): any;

/**
* Prepares given value to a value to be persisted, based on its column type.
*/
prepareHydratedValue(value: any, column: ColumnMetadata): any;


}
2 changes: 1 addition & 1 deletion src/driver/DriverOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export interface DriverOptions {
/**
* Database type. Mysql and postgres are the only drivers supported at this moment.
*/
readonly type: "mysql"|"postgres";
readonly type: "mysql"|"postgres"|"mariadb";

/**
* Url to where perform connection.
Expand Down
2 changes: 1 addition & 1 deletion src/driver/QueryRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export interface QueryRunner {
/**
* Inserts a new row into given table.
*/
insert(tableName: string, valuesMap: Object, idColumnName?: string): Promise<any>;
insert(tableName: string, valuesMap: Object, idColumn?: ColumnMetadata): Promise<any>;

/**
* Performs a simple DELETE query by a given conditions in a given table.
Expand Down
14 changes: 14 additions & 0 deletions src/driver/error/DriverPoolingNotSupportedError.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
* Thrown if database driver does not support pooling.
*
* @internal
*/
export class DriverPoolingNotSupportedError extends Error {
name = "DriverPoolingNotSupportedError";

constructor(driverName: string) {
super();
this.message = `Connection pooling is not supported by (${driverName}) driver.`;
}

}
Loading

0 comments on commit 7fc08ac

Please sign in to comment.