relq 1.0.89 → 1.0.90

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -475,9 +475,30 @@ function columnToAST(col, schemaKey) {
475
475
  const typeValue = config.$sqlType || (typeof config.$type === 'string' ? config.$type : null) || 'text';
476
476
  const mappedType = mapColumnTypeToPostgres(typeValue);
477
477
  const lowerType = mappedType.toLowerCase();
478
- const precision = config.$precision;
479
- const scale = config.$scale;
480
- const length = config.$length;
478
+ let length = config.$length;
479
+ let precision = config.$precision;
480
+ let scale = config.$scale;
481
+ if (length === undefined && precision === undefined) {
482
+ const paramsMatch = typeValue.match(/\(([^)]+)\)$/);
483
+ if (paramsMatch) {
484
+ const params = paramsMatch[1].split(',').map((s) => s.trim());
485
+ if (params.length === 1 && /^\d+$/.test(params[0])) {
486
+ const val = parseInt(params[0], 10);
487
+ if (LENGTH_TYPES.has(lowerType)) {
488
+ length = val;
489
+ }
490
+ else if (PRECISION_TYPES.has(lowerType)) {
491
+ precision = val;
492
+ }
493
+ }
494
+ else if (params.length === 2 && /^\d+$/.test(params[0]) && /^\d+$/.test(params[1])) {
495
+ if (PRECISION_TYPES.has(lowerType)) {
496
+ precision = parseInt(params[0], 10);
497
+ scale = parseInt(params[1], 10);
498
+ }
499
+ }
500
+ }
501
+ }
481
502
  if (length !== undefined && !LENGTH_TYPES.has(lowerType)) {
482
503
  console.warn(`Warning: length parameter not supported for type '${mappedType}' on column '${schemaKey}'`);
483
504
  }
@@ -441,9 +441,30 @@ export function columnToAST(col, schemaKey) {
441
441
  const typeValue = config.$sqlType || (typeof config.$type === 'string' ? config.$type : null) || 'text';
442
442
  const mappedType = mapColumnTypeToPostgres(typeValue);
443
443
  const lowerType = mappedType.toLowerCase();
444
- const precision = config.$precision;
445
- const scale = config.$scale;
446
- const length = config.$length;
444
+ let length = config.$length;
445
+ let precision = config.$precision;
446
+ let scale = config.$scale;
447
+ if (length === undefined && precision === undefined) {
448
+ const paramsMatch = typeValue.match(/\(([^)]+)\)$/);
449
+ if (paramsMatch) {
450
+ const params = paramsMatch[1].split(',').map((s) => s.trim());
451
+ if (params.length === 1 && /^\d+$/.test(params[0])) {
452
+ const val = parseInt(params[0], 10);
453
+ if (LENGTH_TYPES.has(lowerType)) {
454
+ length = val;
455
+ }
456
+ else if (PRECISION_TYPES.has(lowerType)) {
457
+ precision = val;
458
+ }
459
+ }
460
+ else if (params.length === 2 && /^\d+$/.test(params[0]) && /^\d+$/.test(params[1])) {
461
+ if (PRECISION_TYPES.has(lowerType)) {
462
+ precision = parseInt(params[0], 10);
463
+ scale = parseInt(params[1], 10);
464
+ }
465
+ }
466
+ }
467
+ }
447
468
  if (length !== undefined && !LENGTH_TYPES.has(lowerType)) {
448
469
  console.warn(`Warning: length parameter not supported for type '${mappedType}' on column '${schemaKey}'`);
449
470
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "relq",
3
- "version": "1.0.89",
3
+ "version": "1.0.90",
4
4
  "description": "The Fully-Typed PostgreSQL ORM for TypeScript",
5
5
  "author": "Olajide Mathew O. <olajide.mathew@yuniq.solutions>",
6
6
  "license": "MIT",