Skip to content

Commit deeeff4

Browse files
Numeric fields are returned as float instead of string. Database model and column names are no longer lowercased, preserving their casing
1 parent 463becb commit deeeff4

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
__NOTE__ A fork of the original postgresql connector by w3.fi This version does not lowercase db column names
2+
fixing issue: https://github.com/strongloop/loopback-connector-postgresql/issues/38. Also Strings map to
3+
TEXT synonym type (with no arbitrary upper bound). - [email protected]
4+
15
# loopback-connector-postgresql
26

37
[PostgreSQL](https://www.postgresql.org/), is a popular open-source object-relational database.

lib/postgresql.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@ const debugData = require('debug')('loopback:connector:postgresql:data');
1818
const debugSort = require('debug')('loopback:connector:postgresql:order');
1919
const Promise = require('bluebird');
2020

21+
/**
22+
* Postgresql now returns numeric fields as float instead of string.
23+
*/
24+
postgresql.types.setTypeParser(1700, function(val) {
25+
return val === null ? null : parseFloat(val)
26+
});
27+
2128
/**
2229
*
2330
* Initialize the PostgreSQL connector against the given data source
@@ -379,11 +386,7 @@ PostgreSQL.prototype.fromColumnValue = function(prop, val) {
379386
* @returns {String} The converted name
380387
*/
381388
PostgreSQL.prototype.dbName = function(name) {
382-
if (!name) {
383-
return name;
384-
}
385-
// PostgreSQL default to lowercase names
386-
return name.toLowerCase();
389+
return name; //W3 Group Finland Bugfix: Preserve case of database column names
387390
};
388391

389392
function escapeIdentifier(str) {

0 commit comments

Comments
 (0)