Skip to content
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

Cannot insert numbers into postgresql incorrect binary data format #404

Closed
CMCDragonkai opened this issue Dec 15, 2022 · 4 comments
Closed
Labels
bug Something isn't working duplicate This issue or pull request already exists

Comments

@CMCDragonkai
Copy link

Describe the bug

See title.

I'm using:

    "dob_year": {
      "type": "number",
      "optional": true,
      "subtype": "u32",
      "range": {
        "high": 2022,
        "low": 1900,
        "step": 1
      }
    },
    "dob_month": {
      "type": "number",
      "optional": true,
      "subtype": "u32",
      "range": {
        "high": 12,
        "low": 1,
        "step": 1
      }
    },

To Reproduce
Steps to reproduce the behavior:

  1. Schema (if applicable)
CREATE TABLE "customers" (
  "id" uuid DEFAULT gen_random_uuid(),
  "name" text NOT NULL,
  "email" text NOT NULL UNIQUE,
  "phone_number" text,
  "address_line_1" text,
  "address_line_2" text,
  "address_post_code" text,
  "address_state" text,
  "address_country" text,
  "dob_year" smallint CHECK (dob_year > 1900 AND dob_year <= 9999),
  "dob_month" smallint CHECK (dob_month > 0 AND dob_month <= 12),
  "notes" text NOT NULL DEFAULT '',
  "has_sms_allowed" boolean NOT NULL DEFAULT false,
  "has_email_allowed" boolean NOT NULL DEFAULT false,
  "created_on" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
  "updated_on" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (id)
);
  1. See error
[2022-12-15T08:57:39Z WARN  synth::datasource::relational_datasource] Trying to put an unsigned u32 into a int2 typed column customers.dob_month
Error: At namespace "fixtures"

Caused by:
    0: Failed to insert data for collection customers
    1: One or more database inserts failed: error returned from database: incorrect binary data format in bind parameter 7: incorrect binary data format in bind parameter 7

Expected behavior

It should just insert the numbers.

Screenshots
If applicable, add screenshots to help explain your problem.

Environment (please complete the following information):

  • OS: [e.g. Linux, MacOS, Windows]
  • Version: 0.6.5

Additional context
Add any other context about the problem here.


Would be nice to see what the SQL is being generated to understand the problem.

@CMCDragonkai CMCDragonkai added the bug Something isn't working label Dec 15, 2022
@iamwacko iamwacko added the duplicate This issue or pull request already exists label Dec 16, 2022
@iamwacko
Copy link
Contributor

int2 hasn't been implemented yet. This was first reported with #271.

@CMCDragonkai
Copy link
Author

Why can't it just insert the number? The SQL expression looks the same whether it is a smallint or something else.

@iamwacko
Copy link
Contributor

If you read the error closely you see error returned from database. The SQL expression's might look the same, but they aren't to the server.

@iamwacko
Copy link
Contributor

int2 is now implemented in the codebase, but until the next release you will have to compile from source to get it to work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants