Skip to content

How to disable lowercase for models, tables and fields? #116

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Sogl opened this issue Oct 31, 2015 · 8 comments
Closed

How to disable lowercase for models, tables and fields? #116

Sogl opened this issue Oct 31, 2015 · 8 comments

Comments

@Sogl
Copy link

Sogl commented Oct 31, 2015

Hi!

I use loopback with my postgres DB and found a problem. All my models, tables and fields become lowercase.

What I create in arc:
image

And finally what I see in DB after pressing Migrate Model button:
image

I use CamelCase and for me it's very bad moment.

@superkhau
Copy link
Contributor

@crandmck Do we have docs explaining how to convert case or whether it's possible or not?

@crandmck
Copy link
Contributor

crandmck commented Nov 3, 2015

No, we don't have docs for specifying table name case preferences for auto-migration, and:

  1. I'm not even sure if it's consistent across all dbs that support auto-migration.
  2. I don't know how one would change this behavior. I suspect it's not supported (without modifying the connector implementation), but I don't know for sure.
  3. Would this be database-specific? I would presume so, since each connector implements auto-migration itself.

@raymondfeng would know.

@Sogl
Copy link
Author

Sogl commented Nov 3, 2015

@crandmck,
I also found this issue:
#38

And fork with changes to fix some parts of the problem:
https://github.com/W3GroupFinland/loopback-connector-postgresql

Any chance to merge?

@Sogl
Copy link
Author

Sogl commented Nov 3, 2015

Also I found bug with discovery models. If I discover model and try to migrate it after change (or without any change) in Strongloop Arc - I see error column %name% already exists.
But the same situation with manually creating model in arc works fine. I can create model from scratch and migrate it many times (with and without changes).

My module versions:

@crandmck
Copy link
Contributor

crandmck commented Nov 3, 2015

@Sogl It looks like #38 covers this bug. You can ask @raymondfeng about merging it.

Re: the above bug, please open a separate issue. I'll close this one.

@crandmck crandmck closed this as completed Nov 3, 2015
@phanithinks
Copy link

@crandmck Hi is this issue is resolved?, because i got the same issue in the version 2.8.0.

@crandmck
Copy link
Contributor

I don't know. Maybe @raymondfeng knows?

@howientc
Copy link

I've found a simple solution to keeping mixed case that doesn't require modifying the connector source. I am running version 3.1.0 of loopback-connector-postgresql

Example: In a boot script (server/boot/z_my_script.js):

// First get my DataStore that runs on postgres:
const server = require('../server');
const ds = server.dataSources.myDataSource;

// override PostgreSQL.prototype.dbName in postgresql.js: 
ds.connector.dbName = name => name // just use the name as-is!

I also have a call to DataSource.discoverAndBuildModels which I used to generate a model for a database view. That, too, has issues with case that can be solved by explicitly passing nameMapper:null as below:

ds.discoverAndBuildModels(v.name, {visited: {}, associations: true, nameMapper: null})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants