Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft: Add filter tests for discussion #356

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions graphene_sqlalchemy/filters.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class FloatFilter:
pass
31 changes: 30 additions & 1 deletion graphene_sqlalchemy/tests/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
func, select)
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.ext.hybrid import hybrid_property
from sqlalchemy.orm import column_property, composite, mapper, relationship
from sqlalchemy.orm import backref, column_property, composite, mapper, relationship

PetKind = Enum("cat", "dog", name="pet_kind")

Expand Down Expand Up @@ -39,6 +39,7 @@ class Pet(Base):
pet_kind = Column(PetKind, nullable=False)
hair_kind = Column(Enum(HairKind, name="hair_kind"), nullable=False)
reporter_id = Column(Integer(), ForeignKey("reporters.id"))
legs = Column(Integer(), default=4)


class CompositeFullName(object):
Expand Down Expand Up @@ -76,13 +77,41 @@ def hybrid_prop(self):
composite_prop = composite(CompositeFullName, first_name, last_name, doc="Composite")


articles_tags_table = Table(
"articles_tags",
Base.metadata,
Column("article_id", ForeignKey("articles.id")),
Column("tag_id", ForeignKey("tags.id")),
)


class Image(Base):
__tablename__ = "images"
id = Column(Integer(), primary_key=True)
external_id = Column(Integer())
description = Column(String(30))


class Tag(Base):
__tablename__ = "tags"
id = Column(Integer(), primary_key=True)
name = Column(String(30))


class Article(Base):
__tablename__ = "articles"
id = Column(Integer(), primary_key=True)
headline = Column(String(100))
pub_date = Column(Date())
reporter_id = Column(Integer(), ForeignKey("reporters.id"))

# one-to-one relationship with image
image_id = Column(Integer(), ForeignKey('images.id'), unique=True)
image = relationship("Image", backref=backref("articles", uselist=False))

# many-to-many relationship with tags
tags = relationship("Tag", secondary=articles_tags_table, backref="articles")


class ReflectedEditor(type):
"""Same as Editor, but using reflected table."""
Expand Down
Loading