Coder Social home page Coder Social logo

name 'Serial' is not defined about piccolo HOT 11 OPEN

hoosnick avatar hoosnick commented on June 26, 2024
name 'Serial' is not defined

from piccolo.

Comments (11)

dantownsend avatar dantownsend commented on June 26, 2024 1

I came across this bug today - you're right, it's caused when creating a migration with a ForeignKey which uses LazyTableReference.

from piccolo.

hoosnick avatar hoosnick commented on June 26, 2024

Serial is not added to extra_imports when rendering the template. Or is it related to --auto?

from piccolo.

dantownsend avatar dantownsend commented on June 26, 2024

Ah, interesting - is this on the most recent version of Piccolo?

I wonder under what situations it happens? Were you adding a foreign key to an existing table, or was this a new table?

from piccolo.

hoosnick avatar hoosnick commented on June 26, 2024

I had this problem with one previous version of Piccolo, and now I'm on the latest version.

When I added a foreign key to my forwarded(migrated) User and Tariff tables for Order table.

piccolo migrations new all --auto
...
...
...
βœ… Finished

It worked for all apps without problems. But when I use the forwards command to migrate:

piccolo migrations forwards all
                          SESSION_AUTH

----------------------------------------------------------------
πŸ‘ 2 migrations already complete
🏁 No migrations need to be run

                              USER

----------------------------------------------------------------
πŸ‘ 4 migrations already complete
🏁 No migrations need to be run

                             COURSE

----------------------------------------------------------------
πŸ‘ 1 migration already complete
⏩ 1 migration not yet run
πŸš€ Running 1 migration:
  - 2023-07-14T19:26:53:114807 [forwards]... ok! βœ”οΈ

                             USERS

----------------------------------------------------------------
πŸ‘ 1 migration already complete
⏩ 1 migration not yet run
πŸš€ Running 1 migration:
  - 2023-07-14T19:26:53:440473 [forwards]... ok! βœ”οΈ

                            MY_APP

----------------------------------------------------------------
The command failed.
name 'Serial' is not defined
For a full stack trace, use --trace

from piccolo.

dantownsend avatar dantownsend commented on June 26, 2024

Yeah, I think I saw this on a previous version of Piccolo. The fix is to manually add the import to the migration file:

from piccolo.columns.column_types import Serial

I need to try and figure out if it's a still a problem (i.e. if you create a new migration does it have this problem, or is it just for migrations created in older versions).

So far I've tried adding a foreign key to an existing table, and that included the Serial import.

from piccolo.

hoosnick avatar hoosnick commented on June 26, 2024

The fix is to manually add the import to the migration file

Yes, I was doing this solution until now. But I thought this issue was a bug because it appeared in my 2-3 projects where different versions of Piccolo were used.

So far I've tried adding a foreign key to an existing table, and that included the Serial import.

So, do I need to migrate my foreign tables first and then add the foreign key? So sorted apps now can't be a help/solution either?

from piccolo.

hoosnick avatar hoosnick commented on June 26, 2024

I had an empty db and empty piccolo_migrations folder (per app) in this try.

piccolo migrations new all --auto
piccolo migrations forwards all

from piccolo.

hoosnick avatar hoosnick commented on June 26, 2024

@dantownsend The problem is with LazyTableReference and was solved when I removed it and imported the model from my other app/tables.py in the tables.py file.

from piccolo.

dantownsend avatar dantownsend commented on June 26, 2024

@hoosnick Ah, that's good to know.

I was trying to find the commit where I thought I'd fixed the Serial import. This sounds like a new bug then with LazyTableReference.

from piccolo.

hoosnick avatar hoosnick commented on June 26, 2024

@dantownsend Has the bug been fixed?

from piccolo.

dantownsend avatar dantownsend commented on June 26, 2024

@hoosnick Not yet - I've had a look into it, but haven't created a PR yet.

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.