Hi,
I was looking for a way to create case_sensitive columns in sqlalchemy/elixir.
For sqlalchemy versions earlier than 0.4.8, there it was a keyword
called 'case_sensitive' that you could pass as argument when creating
a new column, to declare case_sensitive behaviour.
But I have found a post on sqlalchemy'list, where they say that this
this behaviour has changed in sqlalchemy 0.4.8. Now all the columns
that have lower case names are handled as case unsensitive fields, and
the case_sensitive argument has been deprecated:
-
http://groups.google.com/group/sqlalchemy/browse_thread/thread/d78d4118b7cca96?q=sqlalchemy+case_sensitive#32078a7edab232e5
- sqlalchemy changelog:
http://www.sqlalchemy.org/trac/browser/sqlalchemy/tags/rel_0_4_8/CHANGES
How are case insensitive columns declared in Elixir?
I wrote a simple test case to verify this, however, I am also not sure
how a case insensitive should behave with operators like get_by and
filter.
--
My blog on bioinformatics (now in English): http://bioinfoblog.it
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"SQLElixir" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sqlelixir?hl=en
-~----------~----~----~----~------~----~------~--~---
#!/usr/bin/env python
"""
Test case insensitive columns in elixir
"""
from sqlalchemy.exceptions import IntegrityError
import unittest
import doctest
from elixir import *
class individual(Entity):
name = Field(String(20))
def __init__(self, name):
self.name = name
class TestIndividual(unittest.TestCase):
def setUp(self):
metadata.bind = 'sqlite:///:memory:'
setup_all()
create_all()
def test_caseGet(self):
me = individual('giovanni')
# This should always work (same case)
q = session.query(individual).filter_by(name = 'giovanni')
ind1 = q[0]
assert ind1 == me
# This should always work (same case)
ind2 = individual.get_by(name = 'giovanni')
assert ind2 == me
# This should work if individual.name is case insensitive???
ind3 = individual.get_by(name = 'GIOVANNI')
assert ind3 == me
if __name__ == '__main__':
unittest.main()