-
Couldn't load subscription status.
- Fork 95
Closed
Description
When using all_columns() in a M2M Select like this:
from piccolo.columns.column_types import Varchar, LazyTableReference, ForeignKey
from piccolo.columns.m2m import M2M
from piccolo.engine.postgres import PostgresEngine
from piccolo.table import Table
from starlette.applications import Starlette
import uvicorn
DB = PostgresEngine(config={
'host': 'localhost',
'database': 'test',
'user': 'test',
'password': ''
})
class Band(Table):
name = Varchar()
genres = M2M(LazyTableReference("GenreToBand", module_path=__name__))
class Genre(Table):
name = Varchar()
bands = M2M(LazyTableReference("GenreToBand", module_path=__name__))
# This is our joining table:
class GenreToBand(Table):
band = ForeignKey(Band)
genre = ForeignKey(Genre)
async def on_startup():
await Band.select(Band.name, Band.genres(Genre.all_columns(), as_list=True))
app = Starlette(debug=True, on_startup=[on_startup])
if __name__ == '__main__':
uvicorn.run(app, host='127.0.0.1', port=64215)I get:
[..]
File "/piccolo/piccolo/columns/m2m.py", line 53, in <genexpr>
(column.__class__.value_type in safe_types)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: type object 'list' has no attribute 'value_type'
Metadata
Metadata
Assignees
Labels
No labels