def create_db_column(self, column: Column) -> DbColumn:
        db_column = DbColumn()

        db_column.allow_db_null = column.not_null is False
        db_column.column_name = column.name
        db_column.column_ordinal = column.column_ordinal
        db_column.data_type = column.datatype
        db_column.is_key = column.is_key
        db_column.is_read_only = column.is_readonly
        db_column.is_unique = column.is_unique
        db_column.is_auto_increment = column.is_auto_increment
        db_column.is_updatable = column.is_readonly is False and column.is_auto_increment is False

        return db_column
Exemple #2
0
    def setUp(self):
        self._row_id = 1
        self._rows = [("False",), ("True",)]

        self._result_set = create_result_set(ResultSetStorageType.IN_MEMORY, 0, 0)
        cursor = MockCursor(self._rows, ['IsTrue'])

        with mock.patch('ossdbtoolsservice.query.in_memory_result_set.get_columns_info', new=mock.Mock()):
            self._result_set.read_result_to_end(cursor)

        db_column = DbColumn()
        db_column.data_type = 'bool'
        db_column.column_name = 'IsValid'
        db_column.is_key = True
        db_column.column_ordinal = 0

        self._result_set.columns_info = [db_column]

        self._columns_metadata = [EditColumnMetadata(db_column, 'Default Value')]

        self._table_metadata = EditTableMetadata('public', 'TestTable', self._columns_metadata)

        self._row_delete = RowDelete(self._row_id, self._result_set, self._table_metadata)