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

Types generation stays hanging for big enums #474

Closed
bloriot97 opened this issue Jan 16, 2023 · 1 comment
Closed

Types generation stays hanging for big enums #474

bloriot97 opened this issue Jan 16, 2023 · 1 comment

Comments

@bloriot97
Copy link

Good day.

I have tried to create an enum for Iso31661Alpha2 country codes with the following code

CREATE TYPE "Iso31661Alpha2" AS ENUM (
  'AD', 'AE', 'AF', 'AG', 'AI', 'AL', 'AM', 'AO', 'AQ', 'AR', 'AS', 'AT', 'AU', 'AW', 'AX', 'AZ', 'BA', 'BB', 'BD', 'BE', 'BF',
  'BG', 'BH', 'BI', 'BJ', 'BL', 'BM', 'BN', 'BO', 'BQ', 'BR', 'BS', 'BT', 'BV', 'BW', 'BY', 'BZ', 'CA', 'CC', 'CD', 'CF', 'CG',
  'CH', 'CI', 'CK', 'CL', 'CM', 'CN', 'CO', 'CR', 'CU', 'CV', 'CW', 'CX', 'CY', 'CZ', 'DE', 'DJ', 'DK', 'DM', 'DO', 'DZ', 'EC',
  'EE', 'EG', 'EH', 'ER', 'ES', 'ET', 'FI', 'FJ', 'FK', 'FM', 'FO', 'FR', 'GA', 'GB', 'GD', 'GE', 'GF', 'GG', 'GH', 'GI', 'GL',
  'GM', 'GN', 'GP', 'GQ', 'GR', 'GS', 'GT', 'GU', 'GW', 'GY', 'HK', 'HM', 'HN', 'HR', 'HT', 'HU', 'ID', 'IE', 'IL', 'IM', 'IN',
  'IQ', 'IR', 'IS', 'IT', 'JE', 'JM', 'JO', 'JP', 'KE', 'KG', 'KH', 'KI', 'KM', 'KN', 'KP', 'KR', 'KW', 'KY', 'KZ', 'LA', 'LB',
  'LC', 'LI', 'LK', 'IO', 'LR', 'LS', 'LT', 'LU', 'LV', 'LY', 'MA', 'MC', 'MD', 'ME', 'MF', 'MG', 'MH', 'MK', 'ML', 'MM', 'MN',
  'MS', 'MT', 'MU', 'MV', 'MW', 'MX', 'MY', 'MZ', 'NA', 'NC', 'NE', 'NF', 'NG', 'NI', 'NL', 'NO', 'NP', 'NR', 'NU', 'NZ', 'OM',
  'MO', 'MP', 'MQ', 'MR', 'PA', 'PE', 'PF', 'PG', 'PH', 'PK', 'PL', 'PM', 'PN', 'PR', 'PS', 'PT', 'PW', 'PY', 'QA', 'RE', 'RO',
  'RS', 'RU', 'RW', 'SA', 'SB', 'SC', 'SD', 'SE', 'SG', 'SH', 'SI', 'SJ', 'SK', 'SL', 'SM', 'SN', 'SO', 'SR', 'SS', 'ST', 'SV', 
  'SX', 'SY', 'SZ', 'TC', 'TD', 'TF', 'TG', 'TH', 'TJ', 'TK', 'TL', 'TM'
  -- Will sometime stay hanging when we add these countries
  --, 'TN', 'TO', 'TR', 'TT', 'TV'
);

CREATE TABLE test (
    id SERIAL PRIMARY KEY,
    country "Iso31661Alpha2" NOT NULL
);

And generate this query
test.sql:

/* @name getTest */
SELECT * FROM test;

Here is my config

{
  "transforms": [
    {
      "mode": "sql",
      "include": "test.sql",
      "emitTemplate": "{{dir}}/{{name}}.queries.ts"
    }
  ],
  "srcDir": "./",
  "failOnError": true,
  "db": {
    "dbName": "stoikio",
    "user": "user",
    "password": "password",
    "ssl": false
  }
}

For some reasons the query generation will hang randomly (most of the time). I could not find any fixed number of items to reproduce the issue, you might have to remove or add some. Any idea why ?

@bloriot97 bloriot97 changed the title Types generation stay hanging for big enums Types generation stays hanging for big enums Jan 16, 2023
@adelsz
Copy link
Owner

adelsz commented Feb 2, 2023

Thanks for reporting this @bloriot97. It helped find a deeper problem with how we handle TCP streams. Fixed in #487.

@adelsz adelsz closed this as completed Feb 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants