Repository: schemahero/schemahero (go)

Issue:
Add support for pg_vector 
https://github.com/pgvector/pgvector/tree/master

This is a new type for postgres, it's parameterized

Pull request description:
add support for vector type to postgres
Fixes #909 

Patch:
diff --git a/pkg/database/postgres/parameterized.go b/pkg/database/postgres/parameterized.go
index 8199c837..edfe55a2 100644
--- a/pkg/database/postgres/parameterized.go
+++ b/pkg/database/postgres/parameterized.go
@@ -183,6 +183,15 @@ func maybeParseParameterizedColumnType(requestedType string) (string, error) {
 		} else if len(precisionOnlyMatchGroups) == 2 {
 			columnType = fmt.Sprintf("numeric (%s)", precisionOnlyMatchGroups[1])
 		}
+	} else if strings.HasPrefix(requestedType, "vector") {
+		columnType = "vector"
+
+		size := regexp.MustCompile(`vector\s*\(\s*(?P<size>\d*)\s*\)`)
+		sizeMatchGroups := size.FindStringSubmatch(requestedType)
+
+		if len(sizeMatchGroups) == 2 {
+			columnType = fmt.Sprintf("vector (%s)", sizeMatchGroups[1])
+		}
 	}
 
 	return columnType, nil


Test patch:
diff --git a/pkg/database/postgres/parameterized_test.go b/pkg/database/postgres/parameterized_test.go
index 70f43824..86659e39 100644
--- a/pkg/database/postgres/parameterized_test.go
+++ b/pkg/database/postgres/parameterized_test.go
@@ -88,6 +88,16 @@ func Test_maybeParseParameterizedColumnType(t *testing.T) {
 			requestedType:      "numeric  (5,3)",
 			expectedColumnType: "numeric (5, 3)",
 		},
+		{
+			name:               "vector(1533)",
+			requestedType:      "vector(1533)",
+			expectedColumnType: "vector (1533)",
+		},
+		{
+			name:               "vector ( 3)",
+			requestedType:      "vector ( 3)",
+			expectedColumnType: "vector (3)",
+		},
 	}
 
 	for _, test := range tests {