fix: correct PostgreSQL numeric_scale formula and add index SQL test coverage

The numeric_scale extraction used (& 2047) - 1024 which produces negative
values; fixed to & 65535. Added 12 tests for index SQL generation: INCLUDE,
USING, WHERE, COMMENT ON INDEX, type prefix, and combined scenarios.
This commit is contained in:
yavon007
2026-05-03 20:11:44 +08:00
parent 51dfba9829
commit 25f2f46718
2 changed files with 270 additions and 1 deletions
+1 -1
View File
@@ -168,7 +168,7 @@ pub async fn get_columns(
CASE WHEN t.typname = 'numeric' AND a.atttypmod > 0 \
THEN ((a.atttypmod - 4) >> 16) & 65535 ELSE NULL END AS numeric_precision, \
CASE WHEN t.typname = 'numeric' AND a.atttypmod > 0 \
THEN ((a.atttypmod - 4) & 2047) - 1024 ELSE NULL END AS numeric_scale, \
THEN (a.atttypmod - 4) & 65535 ELSE NULL END AS numeric_scale, \
CASE WHEN t.typname IN ('varchar', 'bpchar') AND a.atttypmod > 0 \
THEN a.atttypmod - 4 ELSE NULL END AS character_maximum_length \
FROM pg_attribute a \