Skip to content
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

discoverSchema makes table lower camel case columns to be completely lowercase #1268

Closed
1 of 2 tasks
ariskemper opened this issue Mar 16, 2017 · 10 comments
Closed
1 of 2 tasks
Assignees

Comments

@ariskemper
Copy link

ariskemper commented Mar 16, 2017

Bug or feature request

  • Bug
  • Feature request

Description of feature (or steps to reproduce if bug)

  1. Mysql table with camel case columns
  2. Use discoverSchema to make json model

if table column name is for example zipCode, it will be named zipcode

Link to sample repo to reproduce issue (if bug)

Expected result

Properties part of json model schema

"emailVerified": {
  "type": "Boolean",
  "required": false,
  "length": null,
  "default": 0,
  "mysql": {
    "columnName": "emailVerified",
    "dataType": "tinyint",
    "dataLength": 1,
    "nullable": "Y"
  }
},

Actual result (if bug)

Properties part of json model schema

"emailverified": {
  "type": "Boolean",
  "required": false,
  "length": null,
  "default": 0,
  "mysql": {
    "columnName": "emailVerified",
    "dataType": "tinyint",
    "dataLength": 1,
    "nullable": "Y"
  }
},

Additional information (Node.js version, LoopBack version, etc)

Additional information (Node.js version, LoopBack version, etc)

Node.js: 6.9.2
loopback: 3.4.0
loopback-datasource-juggler: 3.2.0
loopback-connector-mysql: 3.0.0

@jannyHou
Copy link
Contributor

Hi @ariskemper the dependency version has loopback-connector-mysql while your model.json file is using mssql as db specific config. I assume it's a typo but please make sure the config name is the identified to your connector.

@raymondfeng when user discovers a lower camel case property in mssql (e.g. emailVerified), loopback generates an all lowercase property in model (e.g. emailverified), even though the camel case name is mapped in db specific config. Could you confirm is it expected behavior or a bug? Thanks.

@jannyHou
Copy link
Contributor

@raymondfeng Also users are interested in providing a custom naming convention in migration/discovery. details see issue: loopbackio/loopback-connector-mysql#57

Does loopback has its naming convention documented somewhere? Or any link of the strategy we can follow?
If not I am thinking of document it, therefore confirm the strategy with you first :)
And any thought about the suggestion "provide custom naming convention function"?

@ariskemper
Copy link
Author

@jannyHou its not connector specific, because code in loopback-datasource-juggler does this.

@raymondfeng
Copy link
Contributor

Please note that discoverSchema allows options.nameMapper to provide custom name mapping. See https://github.com/strongloop/loopback-datasource-juggler/blob/master/lib/datasource.js#L1304

@jannyHou
Copy link
Contributor

@ariskemper please check comment #1268 (comment)
Will options.nameMapper solve your problem?

@ariskemper
Copy link
Author

ariskemper commented Apr 1, 2017

@raymondfeng @jannyHou i know, it provides options.nameMapper, but i think that camel case named columns should stay camel cased?

@kjdelisle kjdelisle removed the apex label Jul 5, 2017
@stale stale bot added the stale label Sep 3, 2017
@stale
Copy link

stale bot commented Sep 3, 2017

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot closed this as completed Sep 17, 2017
@0candy 0candy removed the triaging label Sep 17, 2017
@stale
Copy link

stale bot commented Sep 17, 2017

This issue has been closed due to continued inactivity. Thank you for your understanding. If you believe this to be in error, please contact one of the code owners, listed in the CODEOWNERS file at the top-level of this repository.

@sureshkodur
Copy link

sureshkodur commented Jul 12, 2019

Hi, I have same issue. How can resolve this issue?

@agnes512
Copy link
Contributor

please check #3343

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

9 participants