shuttle-hq / synth

The Declarative Data Generator
https://www.getsynth.com/
Apache License 2.0
1.39k stars 109 forks source link

bug: generating int2 for postgres gives 'incorrect binary data format' error #271

Closed chesedo closed 1 year ago

chesedo commented 2 years ago

Describe the bug Trying to generate a number for a postgres int2 column gives an 'incorrect binary data format' error.

To Reproduce Steps to reproduce the behavior:

  1. Schema (postgres)
    CREATE TABLE test
    (
    age int2
    )
  2. Schema (Synth)
    {
    "type": "array",
    "length": 1,
    "content": {
    "type": "object",
    "age": {
      "type": "number",
      "subtype": "i64",
      "constant": 5
    }
    }
    }
  3. See error
    
    Error: At namespace "int2"

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

4. Error (postgres logs)

2021-12-23 07:33:04.840 UTC [89] ERROR: incorrect binary data format in bind parameter 1 2021-12-23 07:33:04.840 UTC [89] CONTEXT: unnamed portal parameter $1 2021-12-23 07:33:04.840 UTC [89] STATEMENT: INSERT INTO test (age) VALUES ($1);



**Expected behavior**
According to the [postgres integration](https://www.getsynth.com/docs/integrations/postgres) page the generation should succeed. On a technical level, the integration page is wrong as an `int2` is equivalent to an `i16` which Synth does not have.

**Environment (please complete the following information):**
 - OS: Linux
 - Version: 0.6.2

**Additional context**
A successful fix should restore this [e2e test](https://github.com/getsynth/synth/pull/268/files#diff-5c7f226dd02b2a0c9d5768d724c00b4eee2bbadef264763ec45e8264e54fcfcfR14) and possibly also update the integration page