google / google/python-spanner-orm

[BUG] Tables with string columns defined manually not using `STRING(MAX)`, ie `STRING(1024)` will fail

Đang mở
#165 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Python
Star
41
Fork
17
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

If you create a table directly via sql command and then try to interact with that same db with spanner_orm then it will fail.

```
CREATE TABLE manuallyCreatedTable(
id INT64 NOT NULL,
ProblematicColumn STRING(1024),
) PRIMARY KEY(id);
```

And you create any table. You will get an error like:

```
/usr/local/bin/spanner-orm(8)()
-> sys.exit(main())
/usr/local/lib/python3.9/site-packages/spanner_orm/admin/scripts.py(78)main()
-> args.execute(args)
/usr/local/lib/python3.9/site-packages/spanner_orm/admin/scripts.py(33)migrate()
-> executor.migrate(args.name)
/usr/local/lib/python3.9/site-packages/spanner_orm/admin/migration_executor.py(63)migrate()
-> self._validate_migrations()
/usr/local/lib/python3.9/site-packages/spanner_orm/admin/migration_executor.py(184)_validate_migrations()
-> if (self.migrated(migration_.migration_id) and
/usr/local/lib/python3.9/site-packages/spanner_orm/admin/migration_executor.py(46)migrated()
-> return self._migration_status().get(migration_id, False)
/usr/local/lib/python3.9/site-packages/spanner_orm/admin/migration_executor.py(150)_migration_status()
-> model_from_db = metadata.SpannerMetadata.model(
/usr/local/lib/python3.9/site-packages/spanner_orm/admin/metadata.py(68)model()
-> return cls.models().get(table_name)
/usr/local/lib/python3.9/site-packages/spanner_orm/admin/metadata.py(43)models()
-> tables = cls.tables()
/usr/local/lib/python3.9/site-packages/spanner_orm/admin/metadata.py(80)tables()
-> column_row.field_type(), nullable=column_row.nullable())
> /usr/local/lib/python3.9/site-packages/spanner_orm/admin/column.py(45)field_type()
-> raise error.SpannerError('No corresponding Type for {}'.format(
(Pdb) up
> /usr/local/lib/python3.9/site-packages/spanner_orm/admin/metadata.py(80)tables()
-> column_row.field_type(), nullable=column_row.nullable())
(Pdb) column_row.field_type()
*** spanner_orm.error.SpannerError: No corresponding Type for STRING(1024)`
```

WORKAROUND: You will need to either set `ProblematicColumn ` to `STRING(MAX)` or delete that table.

Leaving this here for future intrepid souls.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.