Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add column type targets to API #366

Merged
merged 26 commits into from
Jul 20, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
26a5007
modify type getter to support displaying DB names
mathemancer Jul 8, 2021
6be9ced
fix unfriendly type names bug, add test for it
mathemancer Jul 8, 2021
b60050d
pass DB types to API and use for column creation
mathemancer Jul 8, 2021
929d514
refactor, add function to get valid target_type for given type
mathemancer Jul 12, 2021
db30fb5
remove TEXT db type for now, improve valid target type map
mathemancer Jul 12, 2021
944922f
add method to MathesarColumn to get target_types for casting
mathemancer Jul 12, 2021
29fc95c
add method for getting valid target types to MathesarColumn
mathemancer Jul 14, 2021
4b69434
modify cast map getter to match with MathesarColumn
mathemancer Jul 14, 2021
e026789
add function to get table with MathesarColumns
mathemancer Jul 14, 2021
e6b3d3e
add mathesar_columns property to Table model
mathemancer Jul 14, 2021
593bdb5
use new enriched columns to return target_types in API
mathemancer Jul 14, 2021
58949cb
fix failing API tests
mathemancer Jul 14, 2021
3bf3638
remove unneeded print statement
mathemancer Jul 14, 2021
8cff309
remove unused engine init arg
mathemancer Jul 14, 2021
69e8021
fix flake8 errors
mathemancer Jul 14, 2021
51e18c2
Merge branch 'master' into column_type_targets
mathemancer Jul 14, 2021
e528311
move new enriched column behavior to sa_columns
mathemancer Jul 15, 2021
2ccdd34
add tests for new MathesarColumn methods
mathemancer Jul 18, 2021
bb6ca09
add test for getting cast map
mathemancer Jul 18, 2021
a59aad3
Merge branch 'master' into column_type_targets
mathemancer Jul 19, 2021
4093f7b
use column index getter in MathesarColumn class
mathemancer Jul 20, 2021
e9c510d
fix column API tests with new column index field
mathemancer Jul 20, 2021
ce20d87
Merge branch 'master' into column_type_targets
mathemancer Jul 20, 2021
3daf865
add tests for column index property
mathemancer Jul 20, 2021
824219d
Merge branch 'master' into column_type_targets
mathemancer Jul 20, 2021
6807e26
change field column_index to index in columns endpoint
mathemancer Jul 20, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
move new enriched column behavior to sa_columns
  • Loading branch information
mathemancer committed Jul 15, 2021
commit e5283115454bff4c3101659d2b5c4c271f707c78
6 changes: 1 addition & 5 deletions mathesar/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,16 +96,12 @@ def name(self):

@cached_property
def sa_columns(self):
return self._sa_table.columns
return self._enriched_column_sa_table.columns

@property
def sa_column_names(self):
return self.sa_columns.keys()

@cached_property
def mathesar_columns(self):
return self._enriched_column_sa_table.columns

def add_column(self, column_data):
return columns.create_column(
self.schema._sa_engine,
Expand Down
4 changes: 2 additions & 2 deletions mathesar/pagination.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ def paginate_queryset(self, queryset, request, table_id):
self.limit = self.default_limit
self.offset = self.get_offset(request)
table = queryset.get(id=table_id)
self.count = len(table.mathesar_columns)
self.count = len(table.sa_columns)
self.request = request
return list(table.mathesar_columns)[self.offset:self.offset + self.limit]
return list(table.sa_columns)[self.offset:self.offset + self.limit]


class TableLimitOffsetPagination(DefaultLimitOffsetPagination):
Expand Down
2 changes: 1 addition & 1 deletion mathesar/utils/tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def get_table_column_types(table):
types = infer_table_column_types(schema.name, table.name, schema._sa_engine)
col_types = {
col.name: t().compile(dialect=schema._sa_engine.dialect)
for col, t in zip(table.mathesar_columns, types)
for col, t in zip(table.sa_columns, types)
if not col.is_default
and not col.primary_key
and not col.foreign_keys
Expand Down
2 changes: 1 addition & 1 deletion mathesar/views/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def list(self, request, table_pk=None):
def retrieve(self, request, pk=None, table_pk=None):
table = Table.objects.get(id=table_pk)
try:
column = table.mathesar_columns[int(pk)]
column = table.sa_columns[int(pk)]
except IndexError:
raise NotFound
serializer = ColumnSerializer(column)
Expand Down