|
1 | 1 | from py.test import raises |
2 | | -from sqlalchemy import Column, Table, case, types |
| 2 | +from sqlalchemy import Column, Table, case, types, select, func |
3 | 3 | from sqlalchemy.dialects import postgresql |
4 | 4 | from sqlalchemy.ext.declarative import declarative_base |
5 | | -from sqlalchemy.orm import composite |
| 5 | +from sqlalchemy.orm import composite, column_property |
6 | 6 | from sqlalchemy.sql.elements import Label |
7 | 7 | from sqlalchemy_utils import ChoiceType, JSONType, ScalarListType |
8 | 8 |
|
@@ -136,6 +136,23 @@ def test_should_choice_convert_enum(): |
136 | 136 | assert graphene_type._meta.enum.__members__['en'].value == 'English' |
137 | 137 |
|
138 | 138 |
|
| 139 | +def test_should_columproperty_convert(): |
| 140 | + |
| 141 | + Base = declarative_base() |
| 142 | + |
| 143 | + class Test(Base): |
| 144 | + __tablename__ = 'test' |
| 145 | + id = Column(types.Integer, primary_key=True) |
| 146 | + column = column_property( |
| 147 | + select([func.sum(func.cast(id, types.Integer))]).where( |
| 148 | + id==1 |
| 149 | + ) |
| 150 | + ) |
| 151 | + |
| 152 | + graphene_type = convert_sqlalchemy_column(Test.column) |
| 153 | + assert graphene_type.kwargs['required'] == False |
| 154 | + |
| 155 | + |
139 | 156 | def test_should_scalar_list_convert_list(): |
140 | 157 | assert_column_conversion(ScalarListType(), graphene.List) |
141 | 158 |
|
|
0 commit comments