Skip to content

Add case insensitivity feature to GenericFunction.#4570

Closed
adrien-berchet wants to merge 12 commits intosqlalchemy:masterfrom
adrien-berchet:case_insensitive_functions
Closed

Add case insensitivity feature to GenericFunction.#4570
adrien-berchet wants to merge 12 commits intosqlalchemy:masterfrom
adrien-berchet:case_insensitive_functions

Conversation

@adrien-berchet
Copy link
Copy Markdown
Contributor

Description

Fixes: #4569

Following this discussion: geoalchemy/geoalchemy2#216
The goal of the PR is to allow the possibility to register case-insensitive GenericFunction(s).
By default, the case-sensitivity is kept in order to keep the current behavior.

Checklist

This pull request is:

  • A documentation / typographical error fix
    • Good to go, no issue or tests are needed
  • A short code fix
    • please include the issue number, and create an issue if none exists, which
      must include a complete example of the issue. one line code fixes without an
      issue and demonstration will not be accepted.
    • Please include: Fixes: #<issue number> in the commit message
    • please include tests. one line code fixes without tests will not be accepted.
  • A new feature implementation
    • please include the issue number, and create an issue if none exists, which must
      include a complete example of how the feature would look.
    • Please include: Fixes: #<issue number> in the commit message
    • please include tests.

Have a nice day!

@adrien-berchet adrien-berchet force-pushed the case_insensitive_functions branch from 82924c4 to 0a8b385 Compare March 27, 2019 19:30
@zzzeek
Copy link
Copy Markdown
Member

zzzeek commented Mar 28, 2019

looks very nice, let's run on CI

@zzzeek zzzeek requested a review from sqla-tester March 28, 2019 14:48
Copy link
Copy Markdown
Collaborator

@sqla-tester sqla-tester left a comment

Choose a reason for hiding this comment

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

OK, this is sqla-tester setting up my work to try to get revision 0a8b385 of this pull request into gerrit so we can run tests and reviews and stuff

@sqla-tester
Copy link
Copy Markdown
Collaborator

New Gerrit review created for change 0a8b385: https://gerrit.sqlalchemy.org/#/c/sqlalchemy/sqlalchemy/+/1178

@adrien-berchet
Copy link
Copy Markdown
Contributor Author

Tests were failing because they are run in parallel in the CI. I forced the sqlalchemy.sql.functions._registry to be reset at each method teardown in order to ensure that this registry is in the proper state for each test.

@zzzeek zzzeek requested a review from sqla-tester March 28, 2019 23:19
Copy link
Copy Markdown
Collaborator

@sqla-tester sqla-tester left a comment

Choose a reason for hiding this comment

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

OK, this is sqla-tester setting up my work to try to get revision 9c84dc8 of this pull request into gerrit so we can run tests and reviews and stuff

@sqla-tester
Copy link
Copy Markdown
Collaborator

Patchset 9c84dc8 added to existing Gerrit review https://gerrit.sqlalchemy.org/#/c/sqlalchemy/sqlalchemy/+/1178

@zzzeek zzzeek requested a review from sqla-tester March 29, 2019 16:54
Copy link
Copy Markdown
Collaborator

@sqla-tester sqla-tester left a comment

Choose a reason for hiding this comment

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

OK, this is sqla-tester setting up my work to try to get revision 60f2da2 of this pull request into gerrit so we can run tests and reviews and stuff

@sqla-tester
Copy link
Copy Markdown
Collaborator

Patchset 60f2da2 added to existing Gerrit review https://gerrit.sqlalchemy.org/#/c/sqlalchemy/sqlalchemy/+/1178

@zzzeek
Copy link
Copy Markdown
Member

zzzeek commented Mar 30, 2019

I wrote a tool to do the imports called zimports, all you do is install it, cd into the sqlalchemy checkout and type "zimports". or give it the filenames you care about. I dont think anyone uses it but it works pretty great over here.

@adrien-berchet
Copy link
Copy Markdown
Contributor Author

Nice tool, thx :)

@zzzeek zzzeek requested a review from sqla-tester March 31, 2019 21:26
Copy link
Copy Markdown
Collaborator

@sqla-tester sqla-tester left a comment

Choose a reason for hiding this comment

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

OK, this is sqla-tester setting up my work to try to get revision f64e7af of this pull request into gerrit so we can run tests and reviews and stuff

@sqla-tester
Copy link
Copy Markdown
Collaborator

Patchset f64e7af added to existing Gerrit review https://gerrit.sqlalchemy.org/#/c/sqlalchemy/sqlalchemy/+/1178

adrien-berchet added a commit to adrien-berchet/geoalchemy2 that referenced this pull request Apr 2, 2019
adrien-berchet added a commit to adrien-berchet/geoalchemy2 that referenced this pull request Apr 2, 2019
@zzzeek zzzeek requested a review from sqla-tester April 2, 2019 17:31
Copy link
Copy Markdown
Collaborator

@sqla-tester sqla-tester left a comment

Choose a reason for hiding this comment

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

OK, this is sqla-tester setting up my work to try to get revision 537fa19 of this pull request into gerrit so we can run tests and reviews and stuff

@sqla-tester
Copy link
Copy Markdown
Collaborator

Patchset 537fa19 added to existing Gerrit review https://gerrit.sqlalchemy.org/#/c/sqlalchemy/sqlalchemy/+/1178

@zzzeek
Copy link
Copy Markdown
Member

zzzeek commented Apr 2, 2019

keep in mind im just waiting for CI to be done i haven't looked at this yet

@adrien-berchet
Copy link
Copy Markdown
Contributor Author

Let me know if you want me to just take over if this is getting tiring but otherwise feel free to keep on it.

It's ok, these talks are very instructive for me so it is much more enjoyable than tiring :-)
But you would probably be much faster than me so if you prefer you can take it over of course.

@zzzeek zzzeek requested a review from sqla-tester April 12, 2019 14:11
Copy link
Copy Markdown
Collaborator

@sqla-tester sqla-tester left a comment

Choose a reason for hiding this comment

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

OK, this is sqla-tester setting up my work to try to get revision 0156bfd of this pull request into gerrit so we can run tests and reviews and stuff

@sqla-tester
Copy link
Copy Markdown
Collaborator

Patchset 0156bfd added to existing Gerrit review https://gerrit.sqlalchemy.org/#/c/sqlalchemy/sqlalchemy/+/1178

@adrien-berchet
Copy link
Copy Markdown
Contributor Author

I am not able to reproduce the failures reported by the CI with Python 2.7. Is it possible to get the docker image used to run the tests please? Or do you have any idea of what is causing this?

@sqla-tester
Copy link
Copy Markdown
Collaborator

mike bayer (zzzeek) wrote:

adrien-berchet@github wrote:

I am not able to reproduce the failures reported by the CI with
Python 2.7. Is it possible to get the docker image used to run the
tests please? Or do you have any idea of what is causing this?

yeah that is a very strange occurrence, and also the sqlalchemy2 gerrit seems to be running which it's not supposed to here so ill try to resolve all this today.

@sqla-tester
Copy link
Copy Markdown
Collaborator

mike bayer (zzzeek) wrote:

adrien-berchet@github wrote:

I am not able to reproduce the failures reported by the CI with
Python 2.7. Is it possible to get the docker image used to run
the
tests please? Or do you have any idea of what is causing this?

yeah that is a very strange occurrence, and also the sqlalchemy2
gerrit seems to be running which it's not supposed to here so ill
try to resolve all this today.

yeah it's kind of a worst case scenario problem where the faliure only happens with the complete tox run, not individual py.test runs and even not if I enable xdist, im going to have it print out what it's seeing but yeah this would be very tough for people new to the test suite to figure out...

@sqla-tester
Copy link
Copy Markdown
Collaborator

mike bayer (zzzeek) wrote:

OH. it's that sqlalchemy2 job getting in and spreading mischief. sqlalchemy2 is taking out that "lib/" folder. I thought and thought, ok HOW can this break things. How can it? it can't break anything, people install a package, lib/ is gone. Nothing will break, right? This breaks! when your CI checks both out in the same directory and the .pycs hang around.

@sqla-tester
Copy link
Copy Markdown
Collaborator

mike bayer (zzzeek) wrote:

recheck

@adrien-berchet
Copy link
Copy Markdown
Contributor Author

OH. it's that sqlalchemy2 job getting in and spreading mischief. sqlalchemy2 is taking out that "lib/" folder. I thought and thought, ok HOW can this break things. How can it? it can't break anything, people install a package, lib/ is gone. Nothing will break, right? This breaks! when your CI checks both out in the same directory and the .pycs hang around.

Oh, that's a tricky CI bug...

Copy link
Copy Markdown
Collaborator

@sqla-tester sqla-tester left a comment

Choose a reason for hiding this comment

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

Adrien Berchet (adrien-berchet) wrote:

(2 comments)

Some tests are still failing after your last commit. It seems it is due to a wrong order when keys are transformed into list. Maybe we should just sort the case-sensitive keys?

  • test/sql/test_deprecations.py (line 288): Remove one empty line

Comment thread lib/sqlalchemy/sql/functions.py Outdated
"different letter cases and might interact with '{}'. "
"GenericFunction objects will be fully case-insensitive in a "
"future release.".format(
list(case_sensitive_reg[identifier].keys()),
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Adrien Berchet (adrien-berchet) wrote:

Maybe we should replace list by sorted so that the key order would be always the same, whatever the Python version is used. The deprecation test would then be easier to write.

@adrien-berchet
Copy link
Copy Markdown
Contributor Author

I see that you pushed a new commit on gerrit and some tests are still failing. How can I get these changes from gerrit to my branch to propose a fix?

@zzzeek zzzeek requested a review from sqla-tester April 15, 2019 17:59
Copy link
Copy Markdown
Collaborator

@sqla-tester sqla-tester left a comment

Choose a reason for hiding this comment

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

OK, this is sqla-tester setting up my work to try to get revision 37d4f33 of this pull request into gerrit so we can run tests and reviews and stuff

@sqla-tester
Copy link
Copy Markdown
Collaborator

Patchset 37d4f33 added to existing Gerrit review https://gerrit.sqlalchemy.org/#/c/sqlalchemy/sqlalchemy/+/1178

@sqla-tester
Copy link
Copy Markdown
Collaborator

mike bayer (zzzeek) wrote:

sorry this has fallen behind. I will be getting to this soon.

@adrien-berchet
Copy link
Copy Markdown
Contributor Author

sorry this has fallen behind. I will be getting to this soon.

No problem, I will see when you have some time to get back to this :)

@adrien-berchet
Copy link
Copy Markdown
Contributor Author

Oh, I realize that my last commit discarded the change log you introduced in patch set 9, sorry about that...

@sqla-tester
Copy link
Copy Markdown
Collaborator

mike bayer (zzzeek) wrote:

Code-Review+2 Workflow+1

@sqla-tester
Copy link
Copy Markdown
Collaborator

Gerrit review https://gerrit.sqlalchemy.org/1178 has been merged. Congratulations! :)

@sqla-tester
Copy link
Copy Markdown
Collaborator

mike bayer (zzzeek) wrote:

Code-Review+2 Workflow+1

@sqla-tester
Copy link
Copy Markdown
Collaborator

Gerrit review https://gerrit.sqlalchemy.org/1241 has been merged. Congratulations! :)

sqlalchemy-bot pushed a commit that referenced this pull request Apr 30, 2019
The :class:`.GenericFunction` namespace is being migrated so that function
names are looked up in a case-insensitive manner, as SQL  functions do not
collide on case sensitive differences nor is this something which would
occur with user-defined functions or stored procedures.   Lookups for
functions declared with :class:`.GenericFunction` now use a case
insensitive scheme,  however a deprecation case is supported which allows
two or more :class:`.GenericFunction` objects with the same name of
different cases to exist, which will cause case sensitive lookups to occur
for that particular name, while emitting a warning at function registration
time.  Thanks to Adrien Berchet for a lot of work on this complicated
feature.

Fixes: #4569
Closes: #4570
Pull-request: #4570
Pull-request-sha: 37d4f33

Change-Id: Ief07c6eb55bf398f6aad85b60ef13ee6d1173109
(cherry picked from commit ede0f2282fc44a6831abfcc562e1ae04661b5739)
@zzzeek
Copy link
Copy Markdown
Member

zzzeek commented Apr 30, 2019

great job,thanks for the above and beyond effort on this!

@adrien-berchet
Copy link
Copy Markdown
Contributor Author

adrien-berchet commented May 2, 2019

Thanks, I'm glad this helps :)
Thanks for you feedback, it was very instructive.
See you in the next PR!

@adrien-berchet adrien-berchet deleted the case_insensitive_functions branch May 2, 2019 07:48
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.

GenericFunction register is case-sensitive

3 participants