FlutterFlow / flutterflow-issues

A community issue tracker for FlutterFlow.
130 stars 26 forks source link

SQLite REAL vs DECIMAL vs INTEGER -> double vs int issues #4859

Closed andro951 closed 6 days ago

andro951 commented 1 week ago

Can we access your project?

Current Behavior

I'm using an SQLite database I made in a FlutterFlow project. I made a Read Query with an output column: WateringFrequencyInDays which is marked as a double. In the SQLite database, the WateringFrequencyInDays column is a REAL. When the value is something like 3.5, it works as expected, and the Query is usable resulting in the value 3.5 as a double. However, if the value is a whole number like 3, the app's page goes blank gray because it isn't converting to double. If I change the output column type to int when the value is 3, it will work correctly. This is very clearly not how it should work since in a REAL column, there can be values with or without decimals and it should be able to cast either of them to a double.

Expected Behavior

Be able to cast values from a REAL column that are whole numbers to a double.

Steps to Reproduce

Create a SQLite database with 2 entries. It should have 1 REAL column. One row should have a whole number like 3, and the other row should have decimal number like 3.5. Create a Read query that marks the return type as double, and make a text widget to display the 3.5 value. Next, make a text widget to display the 3 value still as a double.

Reproducible from Blank

Bug Report Code (Required)

IT43hs7ZuLl6sbhb7c2MbvoypGQnGlgJWq8vkNlRaDYvCIyqOph/eeOlXxduTe2+S3lhHFqgil0y7sGMuPL9KPQpGwuZRZxg+s9IczrNd3q8Sr6qDMyRPnFPN+JRIFSs0MCRmSYkIvFhci0m7zqmAtmuTjPYCZ+/Zwh9f6PHaOI=

Visual documentation

image

MinPH column is a REAL column. values like 5.5 will successfully cast to double where 6 won't.

Environment

- FlutterFlow version: 3.24.2
- Platform: Created on Windows on an Edge browser.  Not working when generating an APK and testing on android.
- Browser name and version: Microsoft edge
- Operating system and version affected:

Additional Information

No response

Alezanello commented 1 week ago

Hello!

I was unable to replicate the issue on my end, so it’s possible I may have missed something. To assist further, I’m sharing a public project link at the end of this message that you can clone. It contains the SQLite file, which you can modify and test to see if you can replicate the behavior.

Steps I followed:

  1. Created a SQLite table with 2 columns of type REAL.
  2. Uploaded the SQLite database and generated a query that returns two columns (real1 and real2, both as DOUBLE).
  3. Queried the data, and in the child widget, displayed the result of the columns. However, the displayed value automatically changes to 3.0, even though the original value in the SQLite DB is 3.

Here’s the project link: Project Link

image.png image.png
Alezanello commented 6 days ago

Closing this issue since we haven't heard back from you. If you are still facing the problem please submit a new issue. Have a great day!

andro951 commented 6 days ago

Thanks for looking into this. I tried out the test project you posted and tried to reproduce the issue with it and my project, but couldn't reproduce the problem. I was eventually able to get it to work with my database as well. I'm not positive what the problem was. I think it's possible that the database wasn't being updated when I changed it and used a new APK to update the app. I started uninstalling the app to make sure the database was up to date, and that seemed to help, but I haven't done a test to show for sure if that's the case. If I can nail it down to that, I'll make a new issue request.