Table code generation with conditional export library
This table:
import 'package:persistence/src/database/type_converters/tsid_type_converter.dart';
CREATE TABLE dynamic_tables (
id INTEGER PRIMARY KEY MAPPED BY `const TsidTypeConverter()`,
name TEXT(512) NOT NULL,
permissions TEXT(512) NOT NULL,
max_entries INTEGER NOT NULL,
version INTEGER NOT NULL
);
Generates the following imports:
import 'package:drift/drift.dart' as i0;
import 'package:persistence/src/database/models/dynamic_database/dynamic_database.drift.dart'
as i1;
import 'package:tsid_dart/src/tsid_stub.dart' as i2;
import 'package:persistence/src/database/type_converters/tsid_type_converter.dart'
as i3;
import 'package:persistence/src/database/models/dynamic_database/dart_sql_type.dart'
as i4;
Problem: In the third import, the code is accessing a private file instead of using the public library:
import 'package:tsid_dart/tsid_dart.dart';
https://pub.dev/packages/tsid_dart package:tsid_dart/tsid_dart.dart file :
export 'src/tsid_stub.dart'
if (dart.library.io) 'src/tsid_default.dart'
if (dart.library.html) 'src/tsid_web.dart';
export 'src/tsid_error.dart';
We're using the import that the analyzer gives us - I'll ask around if there's a way to get the import URI you've used that contributed the type instead of having to go directly to the definition.
It's probably not going to work right now, but we could add support for a workaround that let's you do something like
typedef MyId = Tsid;
class TsidTypeConverter extends TypeConverter<id, MyId> {...}
Then when drift sees that type it could reference MyId instead of the underlying type. That would fix the import problem, but it's also kind of hacky.
Thank you for the fast reply :grin: