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

bug: generating uuid for postgres gives 'incorrect binary data format' error #270

Open
chesedo opened this issue Dec 23, 2021 · 11 comments
Open
Labels
bug Something isn't working

Comments

@chesedo
Copy link
Contributor

chesedo commented Dec 23, 2021

Describe the bug
Trying to generate a uuid to a postgres uuid column fails with a 'incorrect binary data format' error

To Reproduce
Steps to reproduce the behavior:

  1. Schema (Postgres)
CREATE TABLE test
(
	id uuid PRIMARY KEY
)
  1. Schema (Synth)
{
  "type": "array",
  "length": 1,
  "content": {
    "type": "object",
    "id": {
      "type": "string",
      "uuid": {}
    }
  }
}
  1. See error
Error: At namespace "uuid"

Caused by:
    0: Failed to insert data for collection test
    1: One or more database inserts failed: error returned from database: incorrect binary data format in bind parameter 1: incorrect binary data format in bind parameter 1
  1. Error (in the Postgres logs)
2021-12-23 07:18:18.091 UTC [70] ERROR:  incorrect binary data format in bind parameter 1
2021-12-23 07:18:18.091 UTC [70] CONTEXT:  unnamed portal parameter $1
2021-12-23 07:18:18.091 UTC [70] STATEMENT:  INSERT INTO test (id) VALUES
	($1);

Expected behavior
From the Postgres integrations page I expect the uuid postgres type to successfully populate from a synth string generator.

Environment (please complete the following information):

  • OS: Linux
  • Version: 0.6.2

Additional context
A successful fix should restore the e2e test for this type

@MrShutCo
Copy link

Are there any updates to this or workarounds? This tool seems like exactly what I'm looking for, but not being able to generate these uuids is stopping me from being able to use it

@FixKun
Copy link

FixKun commented Mar 26, 2022

Are there any updates to this or workarounds? This tool seems like exactly what I'm looking for, but not being able to generate these uuids is stopping me from being able to use it

You can generate the data into csvs and then import those into database using copy command.

@MrShutCo
Copy link

Thanks for the fast reply!
I've managed to get a workaround doing pretty much the same thing, exporting to json and then using a JS library that can just insert the JSON into pg (https://knexjs.org/)

@ThomWright
Copy link

It seems sqlx converts strings to binary before sending them to the database. The binary representation PostgreSQL expects for the uuid type is different from the bytes representing the formatted string.

This means we can't give sqlx a string representation of a UUID for a uuid column.

See the Encode impl for Uuid and str. Both get converted to bytes, but with different implementations.

Currently UUIDs are generated using the "string" generator.

I haven't managed to get my head around Synth's internal data model yet, but I'm wondering whether the core::graph::Value enum should have another variant to distinguish Uuids from Strings?

@IgorAndrejewZETO
Copy link

I have same issue while trying to generate a uuid to a postgres.

@chesedo
Copy link
Contributor Author

chesedo commented May 16, 2022

@ThomWright you are correct, core::graph::Value should have another variant for Uuids

@balamuralisrinivasan
Copy link

This tool is apt for my needs. however I am struck with the same UUID problem. Since there are multiple parent-child relationships, i am unable to use the workaround like CSV, JSON etc. Can a fix be provided?

@justneedham
Copy link

Ditto ran into the same bug today. Bummer. If I knew Rust I'd chip in. I think Synth is such a great idea

@iamwacko
Copy link
Contributor

iamwacko commented Dec 1, 2022

Yeah, this has been a problem for a while. I will have more time to work on this soon, so I hope this will be fixed soon.

@CMCDragonkai
Copy link

Our database uses alot of foreign keys, without supporting uuid, there's no way to use synth to generate https://www.getsynth.com/docs/content/same-as data for different tables, since our primary keys of our tables are UUID.

@janmullerbb
Copy link

Hi, any progress on it? Our db uses only UUID as a references (ids) so now we can't use synth at all :-(.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

10 participants