不要怂,就是干,撸起袖子干!

Commit 2ab9439d by Jan Aagaard Meier

bug(datatypes) Fix datatypes parsing for mariadb and mssql

1 parent 9b61b5a2
......@@ -48,7 +48,12 @@ ConnectionManager = function(dialect, sequelize) {
ConnectionManager.prototype.refreshTypeParser = function(dataTypes) {
_.each(dataTypes, function (dataType, key) {
if (dataType.hasOwnProperty('parse')) {
if (dataType.types[this.dialectName]) {
var dialectName = this.dialectName;
if (dialectName === 'mariadb') {
dialectName = 'mysql';
}
if (dataType.types[dialectName]) {
this.$refreshTypeParser(dataType);
} else {
throw new Error('Parse function not supported for type ' + dataType.key + ' in dialect ' + this.dialectName);
......
......@@ -78,7 +78,7 @@ Query.prototype.run = function(sql, parameters) {
, value = column.value
, parse = parserStore.get(typeid);
if (value !== null & parse) {
if (value !== null & !!parse) {
value = parse(value);
}
row[column.metadata.colName] = value;
......
......@@ -35,7 +35,7 @@ describe(Support.getTestDialectTeaser('DataTypes'), function() {
types.setTypeParser(oid, 'text', converter);
});
this.sequelize.connectionManager.refreshTypes(DataTypes.postgres); // Reload custom parsers for hstore and geometry
this.sequelize.connectionManager.refreshTypeParser(DataTypes.postgres); // Reload custom parsers for hstore and geometry
break;
default:
this.sequelize.connectionManager.$clearTypeParser();
......@@ -248,7 +248,7 @@ describe(Support.getTestDialectTeaser('DataTypes'), function() {
it('calls parse and stringify for GEOMETRY', function () {
var Type = new Sequelize.GEOMETRY();
if (['postgres', 'mysql'].indexOf(dialect) !== -1) {
if (['postgres', 'mysql', 'mariadb'].indexOf(dialect) !== -1) {
return testSuccess(Type, { type: "Point", coordinates: [125.6, 10.1] });
} else {
// Not implemented yet
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!