strongloop / loopback

LoopBack makes it easy to build modern applications that require complex integrations.
http://loopback.io
Other
13.23k stars 1.2k forks source link

loopback-connector-mysql: dataSource.discoverSchema doesn't read the default value from db #3212

Closed enricop89 closed 7 years ago

enricop89 commented 7 years ago

Description/Steps to reproduce

Hi all,

I am using the dataSource API discoverSchema.. Everything works well except for one thing... the model produced doesn't contain the default value (only for certain type of data). It seems like the API doesn't read the default property from Db.

Example:

Table 'COMPANY':

screen shot 2017-02-20 at 16 16 20

The default value for the field 'logo' is not imported in the Model.json created. Same thing for the creation date, I expected the json with the defaultFn: 'now' but the API doesn't do it.

I am using Node 6.9.2, Loopback 3.2.1, Loopback my sql connector 2.4.1, loopback-datasource-juggler 3.2.0

bajtos commented 7 years ago

While I am not familiar with the mysql connector code myself, it looks like the "discovery" query does not include any information about the default value - see lib/discovery.js#L159-L186.

@enricop89 I think this should be an easy change, would you like to contribute it yourself?

ssh24 commented 7 years ago

Closing this.

Duplicate of https://github.com/strongloop/loopback-connector-mysql/issues/320