Error when a model contains a column_property
See original GitHub issuefrom marshmallow_sqlalchemy import ModelSchema
from sqlalchemy import *
from sqlalchemy.ext.declarative import declared_attr, declarative_base
from sqlalchemy.orm import *
Base = declarative_base()
class Foo(Base):
__tablename__ = 'foo'
id = Column(Integer, primary_key=True)
@declared_attr
def moo(self):
return column_property(select([1337]))
e = create_engine('sqlite:///')
Base.metadata.create_all(e)
s = Session(e)
s.add(Foo())
s.commit()
foo = s.query(Foo).first()
print foo.moo
class FooSchema(ModelSchema):
class Meta:
model = Foo
Traceback
Traceback (most recent call last):
File "satest.py", line 29, in <module>
class FooSchema(ModelSchema):
File "/home/adrian/dev/indico/env/lib/python2.7/site-packages/marshmallow/schema.py", line 116, in __new__
dict_cls=dict_cls
File "/home/adrian/dev/indico/env/lib/python2.7/site-packages/marshmallow_sqlalchemy/schema.py", line 60, in get_declared_fields
declared_fields = mcs.get_fields(converter, opts, base_fields, dict_cls)
File "/home/adrian/dev/indico/env/lib/python2.7/site-packages/marshmallow_sqlalchemy/schema.py", line 94, in get_fields
dict_cls=dict_cls,
File "/home/adrian/dev/indico/env/lib/python2.7/site-packages/marshmallow_sqlalchemy/convert.py", line 105, in fields_for_model
field = base_fields.get(prop.key) or self.property2field(prop)
File "/home/adrian/dev/indico/env/lib/python2.7/site-packages/marshmallow_sqlalchemy/convert.py", line 125, in property2field
field_class = field_class or self._get_field_class_for_property(prop)
File "/home/adrian/dev/indico/env/lib/python2.7/site-packages/marshmallow_sqlalchemy/convert.py", line 186, in _get_field_class_for_property
field_cls = self._get_field_class_for_column(column)
File "/home/adrian/dev/indico/env/lib/python2.7/site-packages/marshmallow_sqlalchemy/convert.py", line 153, in _get_field_class_for_column
return self._get_field_class_for_data_type(column.type)
File "/home/adrian/dev/indico/env/lib/python2.7/site-packages/marshmallow_sqlalchemy/convert.py", line 178, in _get_field_class_for_data_type
'Could not find field column of type {0}.'.format(types[0]))
marshmallow_sqlalchemy.exceptions.ModelConversionError: Could not find field column of type <class 'sqlalchemy.sql.sqltypes.NullType'>.
Issue Analytics
- State:
- Created 7 years ago
- Comments:12 (5 by maintainers)
Top Results From Across the Web
SQLAlchemy Error in elements.py - ColumnClause nor ...
After digging into the python console and importing the module, I produce this error by trying to print the property of the object....
Read more >ORM Internals
Tracks state information at the class level. ColumnProperty. Describes an object attribute that corresponds to a table column. CompositeProperty.
Read more >Solved: Re: Value null to type number error with postgres ...
Hi, What is the column property? ... I have been receiving "Cannot convert value Null to type number " error for a column...
Read more >The Is Nullable Column Property In Power BI
The new Relationships view (or Modeling view – it seems to have two ... the following error when you try to refresh a...
Read more >Meta-schema Manager error messages
The column property property is required but it cannot be found. The loading of the schema file cannot continue. GS-11124. Table table already...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This is a known issue. I’m not quite sure how to solve this since column_properties can return any type. For now, use an explicit field
This works for me.
This seems right as we should only need the property during serialization and dumping. We shouldn’t need it to deserialize and load.