buguroo / peewee2click Goto Github PK
View Code? Open in Web Editor NEWLicense: GNU Lesser General Public License v3.0
License: GNU Lesser General Public License v3.0
When you try to update a non-existing register, a preview message is shown although it is not possible to perform this action:
Changed 0 records.
Registry 1 does not exists.
Preview message and this final message could be changed by an error/info message (for example, the message of the last line "Registry X does not exists").
If a model has a string primary key, you can change it via update. Everything works OK, but it prints a contradictory warning message ("Registry <old_id> doesn't exist")
Example:
/usr/src/app # python -m my_module config js create --id "foobar"
You are about to create the following entry:
id 'miao'
Are you sure? [y/N]: y
The following entry was created:
id 'miao'
# Then the following
/usr/src/app # python -m my_module config js update 'foobar' --id "barfoo"
You are about to update the following record:
id 'foobar'
With the following information:
id barfoo
Are you sure? [y/N]: y
Changed 1 records.
Registry foobar does not exists.
Since peewee treats all ForeignKeyFields as integers (link), the click_options_from_model_fields
wants user to write an integer as an input, and fails if you provide a text option.
I think a solution could be to check if rel_model exists (to ensure that the field is a FK) and then use undocumented method get_db_field
that returns the proper value.
When you try to update a value to None or empty string, a preview message is shown but this values won't appear. It could be represented as "None" and ''.
Fix peewee version to <3.0.0 on setup.py
When you try to update some element's foreign key providing an invalid value (i.e. not existing in the related table), it's stored anyway in DB and prevent you to do further operations on that element.
Example:
# Valid request
/usr/src/app # python -m my_module config url update 1 --force --client 1
Changed 1 records.
client <Client id=1>
id 1
path 'foo'
# Bad request
/usr/src/app # python -m my_module config url update 1 --force --client -1
[...]
bugloader.models.ClientDoesNotExist: Instance matching query does not exist:
SQL: SELECT "t1"."id", "t1"."name" FROM "client" AS t1 WHERE ("t1"."id" = ?)
PARAMS: [-1]
From this moment every single operation gives an error, unless you pass the "-f" option to update the field or delete the row.
When you delete a register whose foreign key exists in other table, both registers will be deleted but only the first one will be shown in the preview message.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.