GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Cell editor doesn't treat INTEGER, NUMERIC inputs right for INSERT or UPDATE · Issue #1952 · sqlitebrowser/sqlitebrowser

Cell editor doesn't treat INTEGER, NUMERIC inputs right for INSERT or UPDATE #1952

New issue
Copy link
New issue
Copy link
Closed
Closed
Cell editor doesn't treat INTEGER, NUMERIC inputs right for INSERT or UPDATE#1952
Copy link
Assignees
MKleusbergmgrojo
Labels
bugConfirmed bugs or reports that are very likely to be bugs.Confirmed bugs or reports that are very likely to be bugs.
Milestone
3.13.1

Description

@mbraeutigam
mbraeutigam
opened on Aug 1, 2019
Issue body actions

Details for the issue

What did you do?

Created a table with CHECK-constraints and inserted data.

DROP TABLE IF EXISTS TEST;
CREATE TABLE TEST (VST INTEGER CONSTRAINT TEST_VST CHECK(typeof(VST)='integer' and VST>=0 and VST<=BST or typeof(VST)='null'),BST INTEGER CONSTRAINT TEST_BST CHECK(typeof(BST)='integer' and BST>=0 and BST>=VST or typeof(BST)='null'), OBJEKTID TEXT UNIQUE);

insert into TEST(VST,BST,OBJEKTID) VALUES (0,200,'A'); -- OK

update TEST set VST=100 WHERE OBJEKTID='A'; -- OK
update TEST set VST=201 WHERE OBJEKTID='A'; -- CONSTRAINT ERROR as supposed, OK

After that, going into the Browse data tab / cell editor and trying to change the value of VST to 50 there will be a constraint error. This happens, because the cell editor tries to update the value as TEXT instead of INTEGER. I know it is possible by how SQLite works, but shouldn't the editor try to parse for the declared storage class in the table definitions and insert/update it as the declared storage class?

What did you expect to see?

Inserting/Updating data as the declared storage class from the table column (table cell edit and cell editor window), if it is parseable as the declared storage class (e.g. via typeof-Check). If not parseable as declared then insert as TEXT.

Right clicking on a value in a table cell of column VST of the previously via SQL inserted values > Copy as SQL should output

INSERT INTO "main"."TEST" ("VST") VALUES (100);

By the way I am not asking the same as mentioned in #622.
My request is not to check for the correct types when inserting but to insert the correct type if the input in the cell editor is correctly parseable.

What did you see instead?

Right clicking on the table cell of the previously via SQL inserted values > Copy as SQL outputs

INSERT INTO "main"."TEST" ("VST") VALUES ('100');

So as expected the value in the cell is treated as TEXT instead of the defined and inserted INTEGER.

Useful extra information

The info below often helps, please fill it out if you're able to. :)

What operating system are you using?

  • Windows: ( version: 10 Pro 64bit )
  • Linux: ( distro: ___ )
  • Mac OS: ( version: ___ )
  • Other: ___

What is your DB4S version?

  • 3.11.2
  • 3.11.1
  • 3.10.1
  • Other: ___

Did you also

  • Try out the latest nightly version: https://github.com/sqlitebrowser/sqlitebrowser#nightly-builds
  • Search for an existing similar issue: https://github.com/sqlitebrowser/sqlitebrowser/issues?utf8=%E2%9C%93&q=is%3Aissue%20

Activity

  1. MKleusberg
    added a commit that references this issue on Aug 1, 2019

    When updating a field try to respect the affinity data type if possible

    74e0df3
  2. MKleusberg
    self-assigned this
    on Aug 1, 2019
  3. MKleusberg
    added
    bugConfirmed bugs or reports that are very likely to be bugs.Confirmed bugs or reports that are very likely to be bugs.
    on Aug 1, 2019
  4. MKleusberg
    added this to the 3.12.0 - Future release milestone on Aug 1, 2019
  5. MKleusberg commented on Aug 1, 2019

    @MKleusberg
    MKleusberg
    on Aug 1, 2019
    Member
    More actions

    Thanks for opening this issue! This is indeed a problem in our code. A bit of background maybe: There are quite a few places where we just treat everything as text in order to avoid checking the data types of all the values all the time - we can't rely solely on the column data types because the user can still decide to enter any other value, and on the other hand checking every single value would be a performance nightmare.

    In your case however this is clearly causing a usage problem and avoiding without any performance gain either. So it definitely needs fixing 😄 Can you check tomorrow's nightly build (it's going to be the same link as in your other issue, but you need to wait until the file is replaced sometime in the night) and see if it's already fixing the issue for you?

  6. mbraeutigam commented on Aug 1, 2019

    @mbraeutigam
    mbraeutigam
    on Aug 1, 2019
    Author
    More actions

    Sure thing, will check tomorrow.

  7. mgrojo commented on Aug 1, 2019

    @mgrojo
    mgrojo
    on Aug 1, 2019
    Member
    More actions

    It's odd that SQLite3 would end up storing the updated data as INTEGER due to the type affinity rules, if there wasn't any check. However the check is performed on the inserted value before any conversion.

  8. mbraeutigam commented on Aug 5, 2019

    @mbraeutigam
    mbraeutigam
    on Aug 5, 2019
    Author
    More actions

    @MKleusberg How is a build of the nightlies triggered or updated? There's still the version 29th of July for download:

    image

  9. chrisjlocke commented on Aug 5, 2019

    @chrisjlocke
    chrisjlocke
    on Aug 5, 2019 via email
    Member
    More actions
    This sometimes occurs when Justin pulls the power on the build server to power his kettle.... ;) The nightlies should be built every night, but sometimes the builds fail due to compilation issues. Just will look into this.... The fact that the .DMGs have also failed would indicate something server-wise...
    Reacted by Justin Clift
    Reacted by Marc Bräutigam and Justin Clift
  10. scottfurry commented on Aug 5, 2019

    @scottfurry
    scottfurry
    on Aug 5, 2019
    Contributor
    More actions

    @chrisjlocke - A spot of tea impacts software delivery?!?!?!?!
    I'm shocked! Shocked, I tell you! 😟 😱 😟 😨 😱 😵

    😜😎

    Reacted by Marc Bräutigam and Justin Clift
  11. mgrojo commented on Aug 5, 2019

    @mgrojo
    mgrojo
    on Aug 5, 2019
    Member
    More actions

    I seems we should raise some funding in order to buy @justinclift a power strip with multiple sockets 😄

    Reacted by Marc Bräutigam and Justin Clift
  12. MKleusberg commented on Aug 10, 2019

    @MKleusberg
    MKleusberg
    on Aug 10, 2019
    Member
    More actions

    The new nightlies are available now 😄

  13. mbraeutigam commented on Aug 12, 2019

    @mbraeutigam
    mbraeutigam
    on Aug 12, 2019
    Author
    More actions

    @MKleusberg I checked it.

    • Input in cells and the editor textfield seems to work now (tested with integers and double/real values).

    • right clicking on the cell and Copy as SQL still copies/outputs strings.
      image

      outputs in Execute SQL window

      INSERT INTO "main"."TEST" ("BST") VALUES ('200');
      

      but for integers the expected SQL statement should be

      INSERT INTO "main"."TEST" ("BST") VALUES (200);
      

      or for the respective double/real values: (x.y) instead of ('x.y')

  14. mgrojo
    self-assigned this
    on Aug 4, 2024
  15. mgrojo
    modified the milestones: 3.12.0 - Next release, 3.13.1 on Aug 4, 2024
  16. mgrojo
    added a commit that references this issue on Aug 4, 2024

    Return numeric values from model when appropriate

    1ebe7bf
  17. mgrojo commented on Aug 4, 2024

    @mgrojo
    mgrojo
    on Aug 4, 2024
    Member
    More actions
    • right clicking on the cell and Copy as SQL still copies/outputs strings.

    Hi @mbraeutigam. This is fixed in the latest continuous build. Would you mind giving it a try and confirm it's working as expected and I haven't broken anything?

    Let's see if we can close this soon, as currently we have the number of the beast 👿 as number of issues and I don't want any bad luck or whatever 😄

    Reacted by Justin Clift and Marc Bräutigam
  18. mbraeutigam commented on Aug 5, 2024

    @mbraeutigam
    mbraeutigam
    on Aug 5, 2024
    Author
    More actions

    Hi @mgrojo

    Let's see if we can close this soon, as currently we have the number of the beast 👿 as number of issues and I don't want any bad luck or whatever 😄

    On numerics the "Copy as SQL" copies: INSERT INTO "main"."TEST" ("VST") VALUES (50);
    So it is working as expected ✔

    Tested the same but with numeric values in TEXT storage class: INSERT INTO "main"."TEST" ("OBJEKTID") VALUES ('5');.
    Output is also as expected. ✔

    So you can close this issue and get an instant level up for your karma 🚀🤣

  19. mgrojo commented on Aug 5, 2024

    @mgrojo
    mgrojo
    on Aug 5, 2024
    Member
    More actions

    Great! One issue more away from the beast.

    Reacted by Justin Clift
    Reacted by Marc Bräutigam
  20. mgrojo
    closed this as completedon Aug 5, 2024
  21. lucydodo
    added a commit that references this issue on Sep 11, 2024

    Return numeric values from model when appropriate

    0d00785
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @MKleusberg
    MKleusberg
  • @mgrojo
    mgrojo

Labels

bugConfirmed bugs or reports that are very likely to be bugs.Confirmed bugs or reports that are very likely to be bugs.

Type

No type

Projects

No projects

    Milestone

    • 3.13.1

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402503 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.