Coder Social home page Coder Social logo

peewee2click's People

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

miguelsr

peewee2click's Issues

Updating non-existing register shouldn't show preview message

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").

Wrong message after updating primary key.

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.

Can't create a model with non-integer FK

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.

Updating ForeignKey with non-existing reference breaks functionality.

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.

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.