-
-
Notifications
You must be signed in to change notification settings - Fork 338
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3653 from mathesar-foundation/columns_meta_rpc_patch
Columns meta rpc patch
- Loading branch information
Showing
5 changed files
with
144 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,20 @@ | ||
from mathesar.models.base import ColumnMetaData | ||
from mathesar.models.base import ColumnMetaData, Database | ||
|
||
|
||
def get_columns_meta_data(table_oid, database_id): | ||
return ColumnMetaData.filter(database__id=database_id, table_oid=table_oid) | ||
return ColumnMetaData.objects.filter( | ||
database__id=database_id, table_oid=table_oid | ||
) | ||
|
||
|
||
def patch_columns_meta_data(column_meta_data_list, table_oid, database_id): | ||
db_model = Database.objects.get(id=database_id) | ||
for meta_data_dict in column_meta_data_list: | ||
# TODO decide if this is worth the trouble of doing in bulk. | ||
ColumnMetaData.objects.update_or_create( | ||
database=db_model, | ||
table_oid=table_oid, | ||
attnum=meta_data_dict["attnum"], | ||
defaults=meta_data_dict | ||
) | ||
return get_columns_meta_data(table_oid, database_id) |