[PonyORM-list] case sensitive

Alexey Malashkevich alexeymalashkevich at gmail.com
Wed Dec 3 20:58:24 UTC 2014


Hi Arthur,

One of the approaches is to specify the case sensitive collation when you
create your database.If you use only latin1 charaters, then you can use
latin1_general_cs collation. If you use utf8 characters in your
application, then you need to use utf8_bin collation:

CREATE DATABASE db_name
    [[DEFAULT] COLLATE collation_name]

For example:

CREATE DATABASE test COLLATE latin1_general_cs

In this case all selects will be case sensitive. See more information on
this here: http://dev.mysql.com/doc/refman/5.0/en/charset-database.html

If you want only one attribute to be case sensitive, you can use the
sql_type parameter of an attribute when you declare your entities:

class MyEntity(db.Entity):
    attr1 = Required(str, 200, sql_type='VARCHAR(200) COLLATE
latin1_general_cs')
    attr2 = Required(str, 200, sql_type='VARCHAR(200) COLLATE utf8_bin')

In the example above attr1 uses latin1 characters and all selects will be
case sensitive. attr2 uses utf8 characters and will be case sensitive.

Here you can see all available collations for MySQL
http://dev.mysql.com/doc/refman/5.0/en/charset-mysql.html

In future we will add the ability to specify collation for attributes this
way:

class MyEntity(db.Entity):
    attr1 = Required(str, collate='latin1_general_cs')
    attr2 = Required(str, collate='utf8_bin')

Regards,
Alexey


On Wed, Dec 3, 2014 at 5:19 PM, Goldberg, Arthur P <
arthur.p.goldberg at mssm.edu> wrote:

>  Hi All
>
>  I'd like DBMS string searches to case sensitive. THAT is, if 'A' is in
> the dbms, a search for 'a' shouldn't find it.
> but my DBMS is MySQL (on mac), so it is case insensitive
> <http://dev.mysql.com/doc/refman/5.6/en/case-sensitivity.html>.
>
>  thoughts?
>
>
>
>
>
> _______________________________________________
> ponyorm-list mailing list
> ponyorm-list at ponyorm.com
> /ponyorm-list
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </ponyorm-list/attachments/20141204/fabbb398/attachment.html>


More information about the ponyorm-list mailing list