passiomatic / coldsweat

Web RSS aggregator and reader compatible with the Fever API
MIT License
146 stars 21 forks source link

Avoid data truncation for links and GUID's #72

Closed passiomatic closed 9 years ago

passiomatic commented 10 years ago

Sometimes Peewee signals a data truncation for link or GUID fields:

/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/peewee.py:2702: Warning: Data truncated for column 'link' at row 1
  cursor.execute(sql, params or ())

This is caused by the fact that entry links, feed links, and GUID's can exceed the 255 limit of the CharField type (VARCHAR is most databases).

Since we need to have constraints/indices on Feed.self_link and Entry.guid fields one solution could be to switch fields from CharField to TextField, paired with an additional field holding an SHA1 hash (think Feed.self_link_hash, Entry.guid_hash). All the lookups will then be done using SHA1 versions of the links. For consistency Feed.alternate_link will be converted into a TextField too.

See: "MySQL error: key specification without a key length" -- http://stackoverflow.com/questions/1827063/mysql-error-key-specification-without-a-key-length