Skip to content
This repository was archived by the owner on Aug 4, 2022. It is now read-only.
This repository was archived by the owner on Aug 4, 2022. It is now read-only.

unique and/or primary_key have no effect on Redis #73

Open

Description

@SamuelMarks

Test-case

from stdnet.odm import StdModel, CharField, Router

class Bar(StdModel):
    foo = CharField(primary_key=True, unique=True)

if __name__ == '__main__':
    models = Router('redis://localhost:6379?db=1')
    models.register(Bar)

    with models.session().begin() as transaction:
        transaction.add(models.bar.new(foo="Hello world"))
        transaction.add(models.bar.new(foo="Goodbye world"))
    with models.session().begin() as transaction:
        transaction.add(models.bar.new(foo="Hello world"))
        transaction.add(models.bar.new(foo="Goodbye world"))

    for f in models.bar.query().all():
        print '%r = %s' % (f, f.foo)

Output

Bar: Bar object = Hello world
Bar: Bar object = Goodbye world
Bar: Bar object = Hello world
Bar: Bar object = Goodbye world

FYI: I am running python-stdnet 0.8.2 on Python 2.7.5+ with Redis 2.8.2 on Ubuntu. Additionally have tried with python-stdnet 0.9a3.

Activity

  1. lsbardel commented on Jan 5, 2014

    @lsbardel
    Owner

    Replace CharField with SymbolField

  2. SamuelMarks commented on Jan 5, 2014

    @SamuelMarks
    Author

    Thanks, that fixed the problem.

    Why does CharField support unique and primary_key; if neither work?

  3. lsbardel commented on Jan 5, 2014

    @lsbardel
    Owner

    It shouldn't you are right.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions