Skip to content

[firebase_data_connect]: Null Values stored as Empty Strings in DB #17357

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
1 task done
mcfrancho1 opened this issue May 15, 2025 · 1 comment · Fixed by #17373
Closed
1 task done

[firebase_data_connect]: Null Values stored as Empty Strings in DB #17357

mcfrancho1 opened this issue May 15, 2025 · 1 comment · Fixed by #17373
Labels
Needs Attention This issue needs maintainer attention. platform: android Issues / PRs which are specifically for Android. platform: ios Issues / PRs which are specifically for iOS. platform: macos Issues / PRs which are specifically for MacOS. plugin: data_connect type: bug Something isn't working

Comments

@mcfrancho1
Copy link

Is there an existing issue for this?

  • I have searched the existing issues.

Which plugins are affected?

Database, Other

Which platforms are affected?

Android, iOS, macOS

Description

When I tried to store a null float value or string value to the database, the null value is being converted to an empty string and stored to the database.

This should not be the case as null values are meant to be stored.

//schema.gql
type Menu @table(key: "id") {
  id: UUID!
  name: String!
  docRef: String
  index:  Float    
} 

//mutation.gql
mutation SetMenu(
    $id: UUID!
    $name: String!
    $docRef: String
    $sortId: Float
) @auth(level: USER) {
  menu_upsert(
    data: {
      id: $id
      name: $name    
      docRef: $docRef
      sortId: $sortId  
    }
  )
}

//flutter code to set menu
await dbConnector
          .setMenu(
            id: "0420705a-60c0-46c2-8d41-0047e048ca3f,
            name: "Breakfast"
          )
          .sortId(null)
          .docRef(null).execute();

Calling the above will not save the data as the error below will be shown
Error copied from the dataconnect-debug.log
Variables:
{
"docRef": "",
"id": "0420705a-60c0-46c2-8d41-0047e048ca3f",
"name": "White Rice",
"sortId": "",
}
Errors: input: $sortId is invalid Float: unexpected value: with type: string

Taking out sortId from the table and queries stores the data but docRef is an empty string instead of null in the database.

Reproducing the issue

Create the table in the description.
Try adding data.
On VsCode, query the data with SQLTools
Notice that docRef column has empty string instead of null

Firebase Core version

3.9.0

Flutter Version

3.29.2

Relevant Log Output

Variables:
{
   "docRef": "",
   "id": "0420705a-60c0-46c2-8d41-0047e048ca3f",
   "name": "White Rice",
   "sortId": "",
 }
Errors: input: $sortId is invalid Float: unexpected value:  with type: string

Flutter dependencies

Expand Flutter dependencies snippet
  cloud_firestore: ^5.6.0
  firebase_core: ^3.9.0
  firebase_crashlytics: ^4.3.4
  firebase_data_connect: ^0.1.4+1
  firebase_messaging: ^15.1.6
  firebase_storage: ^12.1.3

Additional context and comments

No response

@mcfrancho1 mcfrancho1 added type: bug Something isn't working Needs Attention This issue needs maintainer attention. labels May 15, 2025
@SelaseKay SelaseKay added platform: android Issues / PRs which are specifically for Android. platform: macos Issues / PRs which are specifically for MacOS. platform: ios Issues / PRs which are specifically for iOS. plugin: data_connect labels May 15, 2025
@SelaseKay
Copy link
Contributor

Hi @mcfrancho1, I'm looking into it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Attention This issue needs maintainer attention. platform: android Issues / PRs which are specifically for Android. platform: ios Issues / PRs which are specifically for iOS. platform: macos Issues / PRs which are specifically for MacOS. plugin: data_connect type: bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants