EmpaticoOrg / scenic-mysql_adapter

MySQL adapter for thoughtbot/scenic
MIT License
30 stars 15 forks source link

schema update automatically for all existing views with default value 1 for all fields in view. #7

Closed qumberali22 closed 5 years ago

qumberali22 commented 5 years ago

Here is the example of updated schema:

Correct:
select 
cast(`intellectual_properties`.`start_time` as date) AS `date`,
cast(`intellectual_properties`.`end_time` as date) AS `end_date`,
`intellectual_properties`.`defect_count` AS `defect_count`,
`intellectual_properties`.`label` AS `label` 
from `intellectual_properties`

After automatically update when I run a migration to add column in a table.

Wrong: 
select 
1 AS `date`,
1 AS `end_date`,
1 AS `defect_count`,
1 AS `label`

I don't know why schema is updating with default value 1 for all fields as you can see above, anybody can help?

cainlevy commented 5 years ago

What version of MySQL are you running?

cainlevy commented 5 years ago

This behavior is likely one of the following queries. Would you check each against your server?

https://github.com/EmpaticoOrg/scenic-mysql_adapter/blob/fd15e049f9b9ffc2153f6652cd8a02b435429517/lib/scenic/adapters/my_sql.rb#L81

https://github.com/EmpaticoOrg/scenic-mysql_adapter/blob/fd15e049f9b9ffc2153f6652cd8a02b435429517/lib/scenic/adapters/my_sql.rb#L87

qumberali22 commented 5 years ago

@cainlevy My mysql version is 5.7.22 .Sorry I didn't understand what you are saying in your second comment.

cainlevy commented 5 years ago

Does SHOW CREATE VIEW intellectual_properties return the correct schema, or the wrong schema?

qumberali22 commented 5 years ago

I didn't check that.

qumberali22 commented 5 years ago

@cainlevy This issue is no more.But I don't know how, I just drop my database and then recreate and migrate. Could you please tell me what this issue was?

cainlevy commented 5 years ago

Sorry, I haven't seen this before. If you have the issue again, please try the queries above so we can learn which one is behaving unexpectedly.