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

@SamuelMarks

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.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions