mirror of
https://github.com/strapi/strapi.git
synced 2025-08-22 15:48:59 +00:00
Fix decimal on pg an mysql fix #1273
This commit is contained in:
parent
6de61bd2d6
commit
c82ba4c089
@ -361,7 +361,7 @@ module.exports = function(strapi) {
|
||||
type = definition.client === 'pg' ? 'double precision' : 'double';
|
||||
break;
|
||||
case 'decimal':
|
||||
type = 'decimal';
|
||||
type = 'decimal(10,2)';
|
||||
break;
|
||||
case 'date':
|
||||
case 'time':
|
||||
|
@ -78,8 +78,9 @@ module.exports = strapi => {
|
||||
|
||||
// Make sure the client is installed in the application
|
||||
// `node_modules` directory.
|
||||
let client;
|
||||
try {
|
||||
require(path.resolve(strapi.config.appPath, 'node_modules', connection.settings.client));
|
||||
client = require(path.resolve(strapi.config.appPath, 'node_modules', connection.settings.client));
|
||||
} catch (err) {
|
||||
strapi.log.error('The client `' + connection.settings.client + '` is not installed.');
|
||||
strapi.log.error('You can install it with `$ npm install ' + connection.settings.client + ' --save`.');
|
||||
@ -105,7 +106,10 @@ module.exports = strapi => {
|
||||
migrations: _.get(connection.options, 'migrations')
|
||||
}, strapi.config.hook.settings.knex);
|
||||
|
||||
if (options.client === 'pg' && _.isString(_.get(options.connection, 'schema'))) {
|
||||
if (options.client === 'pg') {
|
||||
client.types.setTypeParser(1700, 'text', parseFloat);
|
||||
|
||||
if (_.isString(_.get(options.connection, 'schema'))) {
|
||||
options.pool = {
|
||||
min: _.get(connection.options, 'pool.min') || 0,
|
||||
max: _.get(connection.options, 'pool.max') || 10,
|
||||
@ -118,6 +122,7 @@ module.exports = strapi => {
|
||||
} else {
|
||||
delete options.connection.schema;
|
||||
}
|
||||
}
|
||||
|
||||
if (options.client === 'mysql') {
|
||||
options.connection.typeCast = (field, next) => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user