oibo8x / subsonicproject

Automatically exported from code.google.com/p/subsonicproject
0 stars 0 forks source link

Subsonic code generation for mysql relys on cached information schema #87

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Man, this caused some bad headaces to me

What steps will reproduce the problem?
1. Setup a mysql server
2. Add a db + table and let subsonic generate the code
3. Add a column to the table and let subsonic generate the code
4. Open the generated file and look if the just created column is added as
a property

What is the expected output? What do you see instead?
The just created column is not added to the ActiveRecord object as a property.

Cause:
Subsonic uses a query like this:

SELECT ...
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_SCHEMA = 'YourDbSchema'

to get the information about your tables from mysql

However, MySql seems to cache these values.
If you execute

SELECT * FROM INFORMATION_SCHEMA.COLUMNS

after a change (column added / column changed from int to double) the
values seem to be cached.

Solution:
Execute "FLUSH TABLES" just before subsonic generates the code.
I provided a patch that does exactly this right before every query in
MySqlInnoDBDataProvider.cs
It is tested and works for me with r522
And because I'm a nice guy I also patched the MySqlDataProvider.cs, but,
didn't test the result. however, that should work, too.

Just one note:
I don't know if the behaviour (don't update information schema after a
change) is wanted or a bug in mysql. I'm running a 5.1.30 under windows.

Original issue reported on code.google.com by j.steinblock@gmail.com on 7 May 2009 at 2:25

Attachments: