Coder Social home page Coder Social logo

Comments (5)

dantownsend avatar dantownsend commented on August 28, 2024

From the DDL for creating the table that you posted:

['CREATE TABLE IF NOT EXISTS "users" ("id" SERIAL PRIMARY KEY NOT NULL, "username" VARCHAR(255) UNIQUE NOT NULL DEFAULT \'\', "email" VARCHAR(255) UNIQUE NOT NULL DEFAULT \'\')']

It looks like it just created the id, username and email columns - not the secret and bio columns.

Maybe try deleting the table from the database, and try it again?

Also, be careful with this User.create_table(if_not_exists=True) it doesn't do anything unless you do the following:

await User.create_table(if_not_exists=True)
# OR
User.create_table(if_not_exists=True).run_sync()

from piccolo.

bedi7 avatar bedi7 commented on August 28, 2024

After changed names from User to Users on fresh database, the same issue ;(.

class Users(Table, db=DB):
    # id = BigSerial(primary_key=True, unique=True, auto_update=True),
    secret = Varchar(length=255, secret=True),
    bio = Varchar(length=255),
    username = Varchar(length=255, unique=True)
    email = Email(length=255, unique=True)

from piccolo.

bedi7 avatar bedi7 commented on August 28, 2024

Debug status from piccolo/table.py in Table.init_subclass

for column bio:

debug

for column username:

debug

I haven't idea why bio object is not recognized as Column class instance if Varchar has the same instance id in both checks.

from piccolo.

dantownsend avatar dantownsend commented on August 28, 2024

I think I see your problem - there's commas after some of the columns:

class Users(Table, db=DB):
    # id = BigSerial(primary_key=True, unique=True, auto_update=True),
    secret = Varchar(length=255, secret=True),   # <- here
    bio = Varchar(length=255),   # <- here
    username = Varchar(length=255, unique=True)
    email = Email(length=255, unique=True)

So Python is treating secret and bio as tuples, instead of just columns.

from piccolo.

bedi7 avatar bedi7 commented on August 28, 2024

Thank you so much for finding such an ugly bug
I continue to play with piccolo-orm

from piccolo.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.