- for columnName, columnJson in columnsJson.iteritems():
- if columnName.startswith('_'):
- raise error.Error("names beginning with \"_\" are reserved",
- json)
- elif not ovs.db.parser.is_identifier(columnName):
- raise error.Error("name must be a valid id", json)
- columns[columnName] = ColumnSchema.from_json(columnJson,
- columnName)
-
- return TableSchema(name, columns, mutable, max_rows, is_root)
+ for column_name, column_json in columns_json.iteritems():
+ _check_id(column_name, json)
+ columns[column_name] = ColumnSchema.from_json(column_json,
+ column_name)
+
+ indexes = []
+ for index_json in indexes_json:
+ index = column_set_from_json(index_json, columns)
+ if not index:
+ raise error.Error("index must have at least one column", json)
+ elif len(index) == 1:
+ index[0].unique = True
+ for column in index:
+ if not column.persistent:
+ raise error.Error("ephemeral columns (such as %s) may "
+ "not be indexed" % column.name, json)
+ indexes.append(index)
+
+ return TableSchema(name, columns, mutable, max_rows, is_root, indexes)