kitensei
kitensei

Reputation: 2530

peewee interpretes conditions in where clause

I am trying to implement peewee ORM in my project, but I have a weird issue:

class Server(peewee.Model):
    name = peewee.CharField

    class Meta:
        database = db


print Server.select().where(Server.name == 'postfix').sql()

returns:

('SELECT `t1`.`id` FROM `server` AS t1 WHERE %s', [False])

Running python 2.7.6 w/ peewee 2.6.4

Upvotes: 0

Views: 405

Answers (1)

thaavik
thaavik

Reputation: 3317

name needs to be an instance of peewee.CharField, not the class itself. So your code should be:

class Server(peewee.Model):
    name = peewee.CharField() # instantiate it!

    class Meta:
        database = db


print Server.select().where(Server.name == 'postfix').sql()

Upvotes: 1

Related Questions