Comments (10)
It's because
user
is a reserved word in Postgres, and having a table with the same name would cause issues
Got it! It explains everything!
Do you think that's the case here?
Definetly It takes place here!
from piccolo.
Looks like types.new_class
will do the trick:
https://docs.python.org/3/library/types.html#types.new_class
from piccolo.
Yeah, looks good! I can have a shot at fixing it tomorrow, if you're not on it already @dantownsend :)
from piccolo.
Should be fixed now - I've push a new build to PyPI.
from piccolo.
@NewDay1313 Piccolo checks in case a Table
has a tablename of 'user'
. For example, either of these:
class User(Table):
...
class MyTable(Table, tablename='user'):
...
It's because user
is a reserved word in Postgres, and having a table with the same name would cause issues.
Do you think that's the case here?
from piccolo.
So will you change that table name in piccolo?
from piccolo.
I don't think any of the builtin migrations for Piccolo use a tablename of user
.
Check any migration files which Piccolo has created for you, in case any of the reference a table called user
.
If you want you can paste the code here and I'll take a look.
from piccolo.
@dantownsend playing around with this last night I noticed that there might be some inconsistency in how the PROTECTED_TABLENAMES check is applied.
in piccolo/table.py:148
tablename = tablename if tablename else _camel_to_snake(cls.__name__)
if tablename in PROTECTED_TABLENAMES:
raise ValueError(
f"{tablename} is a protected name, please give your table a "
"different name."
)
Can't figure out why, but it seems that tablename will always resolve to cls.__name__
For example, when inheriting from BaseUser:
class User(BaseUser, tablename="my_users"):
pass
The migrations are succesfully generated (using piccolo migrations new my_app --auto
) with manager.add_table("User", tablename="my_users")
How ever, trying to push the migrations with piccolo migrations forwards my_app
gives the same error as mentioned in this thread:
user is a protected name, please give your table a different name.
from piccolo.
@heliumbrain You're right, there is an issue. Good catch.
The problem is here:
piccolo/piccolo/apps/migrations/auto/migration_manager.py
Lines 562 to 570 in 49562c2
Piccolo creates a Table
class, but only sets the tablename afterwards, so it's triggering this warning when the table is called 'user'
. I'll have a read of the docs for type
to see if parameters can be passed to it.
from piccolo.
Closing for now - let me know if the problem still persists. Thanks
from piccolo.
Related Issues (20)
- Fix `load_json` on joined tables
- Support arrays of timestamp / timestamptz / date / time in SQLite
- cockroachDB extremely long query due to Array(UUID()) HOT 3
- Upgrade CockroachDB
- Is there a way to truncate the table? HOT 3
- Add support for `CAST` to convert between types
- Add more operators to `QueryString`
- Add basic math functions
- Add support for collation HOT 1
- Add a `having` clause
- `Serial` field won't work in SQLite if it is not the primary key
- `Serial` field won't updates automatically aftes saving in Postgres
- Are bit types supported? HOT 2
- Add one more Engine for PostgreSQL HOT 7
- Support for callbacks at Table level for create update delete HOT 7
- Auto-created index name have a big chance to clash with the table name or name of some structure in the database. HOT 1
- Pressing Enter in `Reverse 1 migration? [y/N]` still leads to reversing. HOT 2
- Add support for `upper` and `lower`
- Fix type warnings in `playground/commands/run.py`
- Add `Album` table to playground
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from piccolo.