We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 646d451 commit 911762dCopy full SHA for 911762d
1 file changed
schema/table.go
@@ -94,6 +94,26 @@ var (
94
reValidColumnName = regexp.MustCompile(`^[a-z_][a-z\d_]*$`)
95
)
96
97
+// AddCqIds adds the cq_id and cq_parent_id columns to the table and all its relations
98
+// set cq_id as primary key if no other primary keys
99
+func AddCqIDs(table *Table) {
100
+ havePks := len(table.PrimaryKeys()) > 0
101
+ cqIDColumn := CqIDColumn
102
+ if !havePks {
103
+ cqIDColumn.PrimaryKey = true
104
+ }
105
+ table.Columns = append(
106
+ ColumnList{
107
+ cqIDColumn,
108
+ CqParentIDColumn,
109
+ },
110
+ table.Columns...,
111
+ )
112
+ for _, rel := range table.Relations {
113
+ AddCqIDs(rel)
114
115
+}
116
+
117
func NewTablesFromArrowSchemas(schemas []*arrow.Schema) (Tables, error) {
118
tables := make(Tables, len(schemas))
119
for i, schema := range schemas {
0 commit comments