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
3197 DB schema: change_properties to text #2561
Conversation
43cb8c0
to
041303b
Compare
We need a migration unit test in order to be sure this works on all db types. We also need a releasenote newsfragment stating that one need to do buildbot upgrade-master in order to upgrade to the new version of buildbot. |
55101c8
to
a4e0326
Compare
The upgrade is working, but the test is not. i will keep working thru this. before: after: |
@tardyp It looks like this issue may only be occuring with postgresql9.4 and latest sqlalchemy, as the CI tests show. After silently executing, the data_type remains unchanged:
|
@nand0p indeed, this is the pain of the db migrations it never works easily for the 3 dbs we support. That's why we require the CI to pass for those 3 :-} There is already a change property to text migration |
metadata.bind = conn | ||
|
||
change_properties = sautils.Table('change_properties', metadata, autoload=True) | ||
self.assertIsInstance(change_properties.c.property_value.type, sa.Text) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think for sqlite, we dont really care as TEXT and VARCHAR are stored the same anyway. We rather need to check that the property can store > 1024 string.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
makes sense. i will add this test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dont think you added that test
a4e0326
to
f685fc4
Compare
@@ -0,0 +1 @@ | |||
Alters change properties from String to Text. Requires upgrade master. (:bug:`3197`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please change to more user oriented message:
Change properties can now be of unlimited size (previously was max 1024 bytes)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- need a test for >1024 property
- Need better relnotes
c3ff87a
to
a0a6a28
Compare
I can't seem to replicate the mysql issue seen in CI. @tardyp should I ignore the insert test for mysql instead?
UPDATE: i found the issue and am working thru it now. |
75a7741
to
c83d2c9
Compare
@tardyp ready_for_review |
metadata = sa.MetaData() | ||
metadata.bind = conn | ||
random_length = 4096 | ||
random_string = ''.join(choice(ascii_lowercase) for byte in range(random_length)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well "x"*4096 would have been enough..
# Using raw sql due to error via sa | ||
# q = conn.execute(sa.select([sa.func.length(change_properties.c.property_value)]).where(changeid==1)) | ||
q = conn.execute("select length(property_value) from change_properties where changeid = 1") | ||
[self.assertEqual(q_length[0], random_length) for q_length in q] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would have prefered you just use the db api to write and read the property back and forth and make sure its not truncated
c83d2c9
to
05f9e04
Compare
@tardyp You're right, there does appear to be an issue with sqlalchemy truncating text fields when they contain large strings. To compensate, I kept the type as string(varchar), but upped to 14336 (1024*14), to deal with mysql limits. http://stackoverflow.com/questions/13506832/what-is-the-mysql-varchar-max-size should we worry about truncation for any of these?
|
395bcee
to
c0c360e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If mysql as limitation, we should document that limitation, but we shouldn't workaround like this.
what if pg users want bigger properties?
@@ -314,7 +314,7 @@ class Model(base.DBConnectorComponent): | |||
nullable=False), | |||
sa.Column('property_name', sa.String(256), nullable=False), | |||
# JSON-encoded tuple of (value, source) | |||
sa.Column('property_value', sa.String(1024), nullable=False), | |||
sa.Column('property_value', sa.String(14336), nullable=False), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dont think it is a good idea. We should keep Text, and be coherent with the other property table.
9da4377
to
3e23807
Compare
Alters change_properties.propery_value from String(1024) to Text http://trac.buildbot.net/ticket/3197
3e23807
to
d614f88
Compare
@tardyp ready_for_review |
I dont see the documentation about mysql limitation. Can you document it here (with reference on mysql documentation on why it truncates the text rows) |
@tardyp The mysql limitation only applies to varchar, not text, so it is not relevant anymore now that the table column is altered to text. The truncation I was seeing apparently was a result of evaluating the unicode result array, instead of string. this is fixed and test works as expected. example unicode query result array i was previously erroneously evaluating:
|
thanks! |
Alters change_properties.propery_value from String(1024) to Text
http://trac.buildbot.net/ticket/3197