-
Notifications
You must be signed in to change notification settings - Fork 90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Auto migration not working with JSONB fields #123
Comments
Hmm, strange. I can replicate this locally - will try and figure it out. |
Indeed strange... I just tried creating a new project with a new venv and a newly scaffold ASGI app. It seems to work fine. This might just be my environment acting up. Sorry for the noise. Will dig in to it a bit more though. |
Ok, so it only seems to happen after adding a new JSONB field to a table... In a completely new project, only installing dependencies and running class Task(Table):
"""
An example table.
"""
name = Varchar()
completed = Boolean(default=False)
data = JSONB() ~/tmp-dev/piccolo-issue-123-2 via 🐍 v3.9.4 (.venv)
❯ piccolo migrations new home --auto
Running Postgres version 12.5
Creating new migration ...
Created tables 1
Dropped tables 0
Renamed tables 0
Created table columns 3
Dropped columns 0
Columns added to existing tables 0
Renamed columns 0
Altered columns 0 Then after updating Table: class Task(Table):
"""
An example table.
"""
name = Varchar()
completed = Boolean(default=False)
data = JSONB()
data2 = JSONB() ~/tmp-dev/piccolo-issue-123-2 via 🐍 v3.9.4 (.venv) took 2s
❯ piccolo migrations new home --auto
Running Postgres version 12.5
Creating new migration ...
The command failed.
Replacement index 0 out of range for positional args tuple |
Hmm, it seems to happen no matter if you try to add a new JSONB (or any other field for that matter) or not. Even running the |
Yeah, seems to be an issue when Piccolo is trying to check which columns have been added. It uses sets to do this. piccolo/piccolo/apps/migrations/auto/diffable_table.py Lines 67 to 76 in 98de5b6
Under the hood it seems like sets call the I need to work out a different way to check equality between columns without triggering this custom Or just refactor the code I added, so |
@heliumbrain Should be fixed now - it's on PyPI. Give it a go when you have a chance. I need to add a new Github action, which will try and run a big suite of migration files to catch these edge cases. |
@dantownsend that's fast, great job :) Working as expected now 👍 |
Hello!
@dantownsend I'm afraid something in #122 made the migration manager sad at the sight of a JSONB field.
piccolo migrations new blog --auto
And with orjson:
It works fine with JSON. And both JSON and JSONB works in 0.23.0.
My knowledge of JSONB is very lacking, and I have no clue how to find the cause of this
The text was updated successfully, but these errors were encountered: