Skip to content
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

Fix MySQL case-insensitive search, order by id when looking for next short code #17

Closed
wants to merge 7 commits into from

Conversation

Hu1-Li
Copy link
Contributor

@Hu1-Li Hu1-Li commented May 17, 2018

  1. fix bug when getting latest short code using order by link.id
  2. fix bug when comparing two short code using collate

1. fix bug when getting latest short code using order by link.id
2. fix bug when comparing two short code using collate
Tested using sqlite3 and mysql; Psql is not tested.
@coveralls
Copy link

coveralls commented May 18, 2018

Coverage Status

Coverage increased (+0.1%) to 53.917% when pulling 7185d7c on Hu1-Li:issue15 into 863fc7a on amitt001:master.

Copy link
Owner

@amitt001 amitt001 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for not getting back early. Please make comment changes, squash the commits in one and rebase the branch with the master when done.

table=Link.__tablename__
)
).execute_if(dialect='mysql')
)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am sure it would be a good idea to write migrations here. This will clutter the code.

Instead of doing alter table we after the table is created one solution is to do

if config.database['engine'] == 'mysql':
    short_code_data_type = Unicode(6, collation="utf8_bin")
else:
    short_code_data_type = Unicode(6)

short_code = Column(short_code_data_type, unique=True, index=True, default=None)

This handles MySql case. As postgresql and sqliet are already case sensitive.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will also require moving DatabaseFactory import in initialize.py to initialize_db function.

@amitt001 amitt001 changed the title Issue15 Fix MySQL case-insensitive search, order by id when looking for next short code May 21, 2018
@Hu1-Li
Copy link
Contributor Author

Hu1-Li commented May 22, 2018

This is my first time working with CI, I think i can do better next time, sorry for the inconvenient.

As for merging these commits into one commit, you can select squash and merge in here
screen shot 2018-05-22 at 20 13 00

@amitt001
Copy link
Owner

amitt001 commented May 27, 2018

Fixes #15

Squashed your commits and fixed with commit 67260ba

@Hu1-Li your initial event.listen way of altering in case of MySQL was better as checking config.database['engine'] == 'mysql' in Link class made it unusable for directly importing and using it. It became dependent on config. Sorry for all the rework.

Thanks for fixing this.

@amitt001 amitt001 closed this May 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants