loopback switches postgres decimal type to integer on autoupdate
In my model i have a "scale" property, and it should set the postgresql type to decimal
however, everytime i run autoupdate, it switches the postgres type to integer,
"scale": {
"type": "number",
"postgresql": {
"dataType": "decimal"
},
"required": true,
"default": 1.0
},
can anyone help? thanks
@benjaminhon how did you find out that the postgres type is integer? using some 3rd party tool like pdAmdin 4 ?
Based on the info posted above, cannot say much, but I can share some ideas for a next step to help you debug it in your environment. For example, test code in the package may be a resource to modify and see what happens: https://github.com/strongloop/loopback-connector-postgresql/blob/master/test/postgresql.autoupdate.test.js
there was a problem with the postgres loopback connector 3.0 , i reverted back to 2.8 and it worked
On Sat, Jul 1, 2017 at 6:23 AM, Tetsuo Seto [email protected] wrote:
@benjaminhon https://github.com/benjaminhon how did you find out that the postgres type is integer? using some 3rd party tool like pdAmdin 4 ?
Based on the info posted above, cannot say much, but I can share some ideas for a next step to help you debug it in your environment. For example, test code in the package may be a resource to modify and see what happens: https://github.com/strongloop/loopback-connector-postgresql/ blob/master/test/postgresql.autoupdate.test.js
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/strongloop/loopback/issues/3467#issuecomment-312385678, or mute the thread https://github.com/notifications/unsubscribe-auth/AHzqCOqaIjuQcyVEUKc8cBMswLkQHzkYks5sJXVfgaJpZM4OHzHU .
yep i was using postico
On Sat, Jul 1, 2017 at 1:42 PM, Benjamin Hon [email protected] wrote:
there was a problem with the postgres loopback connector 3.0 , i reverted back to 2.8 and it worked
On Sat, Jul 1, 2017 at 6:23 AM, Tetsuo Seto [email protected] wrote:
@benjaminhon https://github.com/benjaminhon how did you find out that the postgres type is integer? using some 3rd party tool like pdAmdin 4 ?
Based on the info posted above, cannot say much, but I can share some ideas for a next step to help you debug it in your environment. For example, test code in the package may be a resource to modify and see what happens: https://github.com/strongloop/loopback-connector-postgresql/ blob/master/test/postgresql.autoupdate.test.js
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/strongloop/loopback/issues/3467#issuecomment-312385678, or mute the thread https://github.com/notifications/unsubscribe-auth/AHzqCOqaIjuQcyVEUKc8cBMswLkQHzkYks5sJXVfgaJpZM4OHzHU .
@kjdelisle @ssh24 -- regression in 3.0.0? @benjaminhon wrote it did not repro with 2.8.0.
This was a regression in [email protected] but is fixed in the latest version i.e [email protected]. Please upgrade the connector version to 3.0.1 to get the patch.
Here is a sample code snippet:
model-definition.json
{
"name": "Item",
"base": "PersistedModel",
"idInjection": true,
"options": {
"validateUpsert": true
},
"properties": {
"name": {
"type": "string"
},
"price": {
"type": "number",
"postgresql": {
"dataType": "decimal"
}
}
},
"validations": [],
"relations": {},
"acls": [],
"methods": {}
}
boot-script.js
'use strict';
var util = require('util');
var _ = require('lodash');
module.exports = function(app) {
var db = app.datasources.postgresDs;
var Item = app.models.Item;
db.autoupdate(function(err) {
if (err) throw err;
console.log('\nAutomigrate completed');
Item.create([{
name: 'Pen',
price: '4.99',
}, {
name: 'paper',
price: 9.99,
}], function(err, result) {
if (err) throw err;
console.log('\nCreated instance: ' + util.inspect(result));
Item.find(function(err, result) {
if (err) throw err;
console.log('\nFound instance: ' + util.inspect(result));
});
});
});
};
output
sakibs-mac:lb-3467 ssh$ node .
Web server listening at: http://0.0.0.0:3000
Browse your REST API at http://0.0.0.0:3000/explorer
Automigrate completed
Created instance: [ { name: 'Pen', price: 4.99, id: 2 },
{ name: 'paper', price: 9.99, id: 1 } ]
Found instance: [ { name: 'paper', price: '9.99', id: 1 },
{ name: 'Pen', price: '4.99', id: 2 } ]
table schema
testdb=# \d item
Table "public.item"
Column | Type | Modifiers
--------+---------+---------------------------------------------------
name | text |
price | numeric |
id | integer | not null default nextval('item_id_seq'::regclass)
Indexes:
"item_pkey" PRIMARY KEY, btree (id)
ahh great thanks
On Tue, Jul 4, 2017 at 3:02 AM, Tetsuo Seto [email protected] wrote:
Closed #3467 https://github.com/strongloop/loopback/issues/3467.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/strongloop/loopback/issues/3467#event-1148592097, or mute the thread https://github.com/notifications/unsubscribe-auth/AHzqCLED3foZKcBSMzFIV2CS0Gor3ua_ks5sKTqugaJpZM4OHzHU .