Skip to content

Is is possible to use .as_alias() for Json field from a joined table? #551

Answered by dantownsend
Anton-Karpenko asked this question in Q&A
Discussion options

You must be logged in to vote

@Anton-Karpenko You're right this is a bug. I was able to replicate it using this script:

import asyncio

from piccolo.table import Table, create_db_tables, drop_db_tables
from piccolo.columns import Varchar, JSONB, ForeignKey
from piccolo.engine.sqlite import SQLiteEngine

DB = SQLiteEngine()

class User(Table, tablename="my_user", db=DB):
    name = Varchar(length=120)
    config = JSONB(default={})


class Subscriber(Table, tablename="subscriber",  db=DB):
    name = Varchar(length=120)
    user = ForeignKey(references=User)


async def main():
    await drop_db_tables(User, Subscriber)
    await create_db_tables(User, Subscriber)
    user = await User.objects().create(name="Bob")
    a…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@Anton-Karpenko
Comment options

@dantownsend
Comment options

@Anton-Karpenko
Comment options

Answer selected by Anton-Karpenko
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants