mirror of https://github.com/AMT-Cheif/drift.git
Merge pull request #2625 from ValentinVignal/drift-dev/add-actual-table-name-static
[drift_dev] Add the static const `$name` to table
This commit is contained in:
commit
4be60e7cf7
|
@ -39,9 +39,10 @@ class Todos extends i0.Table with i0.TableInfo<Todos, i1.Todo> {
|
|||
@override
|
||||
List<i0.GeneratedColumn> get $columns => [id, title, content, category];
|
||||
@override
|
||||
String get aliasedName => _alias ?? 'todos';
|
||||
String get aliasedName => _alias ?? actualTableName;
|
||||
@override
|
||||
String get actualTableName => 'todos';
|
||||
String get actualTableName => $name;
|
||||
static const String $name = 'todos';
|
||||
@override
|
||||
i0.VerificationContext validateIntegrity(i0.Insertable<i1.Todo> instance,
|
||||
{bool isInserting = false}) {
|
||||
|
@ -280,9 +281,10 @@ class Categories extends i0.Table with i0.TableInfo<Categories, i1.Category> {
|
|||
@override
|
||||
List<i0.GeneratedColumn> get $columns => [id, description];
|
||||
@override
|
||||
String get aliasedName => _alias ?? 'categories';
|
||||
String get aliasedName => _alias ?? actualTableName;
|
||||
@override
|
||||
String get actualTableName => 'categories';
|
||||
String get actualTableName => $name;
|
||||
static const String $name = 'categories';
|
||||
@override
|
||||
i0.VerificationContext validateIntegrity(i0.Insertable<i1.Category> instance,
|
||||
{bool isInserting = false}) {
|
||||
|
|
|
@ -26,9 +26,10 @@ class $TodoCategoriesTable extends TodoCategories
|
|||
@override
|
||||
List<GeneratedColumn> get $columns => [id, name];
|
||||
@override
|
||||
String get aliasedName => _alias ?? 'todo_categories';
|
||||
String get aliasedName => _alias ?? actualTableName;
|
||||
@override
|
||||
String get actualTableName => 'todo_categories';
|
||||
String get actualTableName => $name;
|
||||
static const String $name = 'todo_categories';
|
||||
@override
|
||||
VerificationContext validateIntegrity(Insertable<TodoCategory> instance,
|
||||
{bool isInserting = false}) {
|
||||
|
@ -225,9 +226,10 @@ class $TodoItemsTable extends TodoItems
|
|||
List<GeneratedColumn> get $columns =>
|
||||
[id, title, content, categoryId, generatedText];
|
||||
@override
|
||||
String get aliasedName => _alias ?? 'todo_items';
|
||||
String get aliasedName => _alias ?? actualTableName;
|
||||
@override
|
||||
String get actualTableName => 'todo_items';
|
||||
String get actualTableName => $name;
|
||||
static const String $name = 'todo_items';
|
||||
@override
|
||||
VerificationContext validateIntegrity(Insertable<TodoItem> instance,
|
||||
{bool isInserting = false}) {
|
||||
|
|
|
@ -67,4 +67,7 @@ void main() {
|
|||
),
|
||||
);
|
||||
});
|
||||
test('Table classes expose the name of the sql table', () {
|
||||
expect($TodosTableTable.$name, 'todos');
|
||||
});
|
||||
}
|
||||
|
|
|
@ -18,9 +18,10 @@ class NoIds extends Table with TableInfo<NoIds, NoIdRow> {
|
|||
@override
|
||||
List<GeneratedColumn> get $columns => [payload];
|
||||
@override
|
||||
String get aliasedName => _alias ?? 'no_ids';
|
||||
String get aliasedName => _alias ?? actualTableName;
|
||||
@override
|
||||
String get actualTableName => 'no_ids';
|
||||
String get actualTableName => $name;
|
||||
static const String $name = 'no_ids';
|
||||
@override
|
||||
VerificationContext validateIntegrity(Insertable<NoIdRow> instance,
|
||||
{bool isInserting = false}) {
|
||||
|
@ -118,9 +119,10 @@ class WithDefaults extends Table with TableInfo<WithDefaults, WithDefault> {
|
|||
@override
|
||||
List<GeneratedColumn> get $columns => [a, b];
|
||||
@override
|
||||
String get aliasedName => _alias ?? 'with_defaults';
|
||||
String get aliasedName => _alias ?? actualTableName;
|
||||
@override
|
||||
String get actualTableName => 'with_defaults';
|
||||
String get actualTableName => $name;
|
||||
static const String $name = 'with_defaults';
|
||||
@override
|
||||
VerificationContext validateIntegrity(Insertable<WithDefault> instance,
|
||||
{bool isInserting = false}) {
|
||||
|
@ -314,9 +316,10 @@ class WithConstraints extends Table
|
|||
@override
|
||||
List<GeneratedColumn> get $columns => [a, b, c];
|
||||
@override
|
||||
String get aliasedName => _alias ?? 'with_constraints';
|
||||
String get aliasedName => _alias ?? actualTableName;
|
||||
@override
|
||||
String get actualTableName => 'with_constraints';
|
||||
String get actualTableName => $name;
|
||||
static const String $name = 'with_constraints';
|
||||
@override
|
||||
VerificationContext validateIntegrity(Insertable<WithConstraint> instance,
|
||||
{bool isInserting = false}) {
|
||||
|
@ -557,9 +560,10 @@ class ConfigTable extends Table with TableInfo<ConfigTable, Config> {
|
|||
List<GeneratedColumn> get $columns =>
|
||||
[configKey, configValue, syncState, syncStateImplicit];
|
||||
@override
|
||||
String get aliasedName => _alias ?? 'config';
|
||||
String get aliasedName => _alias ?? actualTableName;
|
||||
@override
|
||||
String get actualTableName => 'config';
|
||||
String get actualTableName => $name;
|
||||
static const String $name = 'config';
|
||||
@override
|
||||
VerificationContext validateIntegrity(Insertable<Config> instance,
|
||||
{bool isInserting = false}) {
|
||||
|
@ -855,9 +859,10 @@ class Mytable extends Table with TableInfo<Mytable, MytableData> {
|
|||
List<GeneratedColumn> get $columns =>
|
||||
[someid, sometext, isInserting, somedate];
|
||||
@override
|
||||
String get aliasedName => _alias ?? 'mytable';
|
||||
String get aliasedName => _alias ?? actualTableName;
|
||||
@override
|
||||
String get actualTableName => 'mytable';
|
||||
String get actualTableName => $name;
|
||||
static const String $name = 'mytable';
|
||||
@override
|
||||
VerificationContext validateIntegrity(Insertable<MytableData> instance,
|
||||
{bool isInserting = false}) {
|
||||
|
@ -1117,9 +1122,10 @@ class Email extends Table
|
|||
@override
|
||||
List<GeneratedColumn> get $columns => [sender, title, body];
|
||||
@override
|
||||
String get aliasedName => _alias ?? 'email';
|
||||
String get aliasedName => _alias ?? actualTableName;
|
||||
@override
|
||||
String get actualTableName => 'email';
|
||||
String get actualTableName => $name;
|
||||
static const String $name = 'email';
|
||||
@override
|
||||
VerificationContext validateIntegrity(Insertable<EMail> instance,
|
||||
{bool isInserting = false}) {
|
||||
|
@ -1341,9 +1347,10 @@ class WeirdTable extends Table with TableInfo<WeirdTable, WeirdData> {
|
|||
@override
|
||||
List<GeneratedColumn> get $columns => [sqlClass, textColumn];
|
||||
@override
|
||||
String get aliasedName => _alias ?? 'Expression';
|
||||
String get aliasedName => _alias ?? actualTableName;
|
||||
@override
|
||||
String get actualTableName => 'Expression';
|
||||
String get actualTableName => $name;
|
||||
static const String $name = 'Expression';
|
||||
@override
|
||||
VerificationContext validateIntegrity(Insertable<WeirdData> instance,
|
||||
{bool isInserting = false}) {
|
||||
|
|
|
@ -47,9 +47,10 @@ class $CategoriesTable extends Categories
|
|||
List<GeneratedColumn> get $columns =>
|
||||
[id, description, priority, descriptionInUpperCase];
|
||||
@override
|
||||
String get aliasedName => _alias ?? 'categories';
|
||||
String get aliasedName => _alias ?? actualTableName;
|
||||
@override
|
||||
String get actualTableName => 'categories';
|
||||
String get actualTableName => $name;
|
||||
static const String $name = 'categories';
|
||||
@override
|
||||
VerificationContext validateIntegrity(Insertable<Category> instance,
|
||||
{bool isInserting = false}) {
|
||||
|
@ -318,9 +319,10 @@ class $TodosTableTable extends TodosTable
|
|||
List<GeneratedColumn> get $columns =>
|
||||
[id, title, content, targetDate, category, status];
|
||||
@override
|
||||
String get aliasedName => _alias ?? 'todos';
|
||||
String get aliasedName => _alias ?? actualTableName;
|
||||
@override
|
||||
String get actualTableName => 'todos';
|
||||
String get actualTableName => $name;
|
||||
static const String $name = 'todos';
|
||||
@override
|
||||
VerificationContext validateIntegrity(Insertable<TodoEntry> instance,
|
||||
{bool isInserting = false}) {
|
||||
|
@ -667,9 +669,10 @@ class $UsersTable extends Users with TableInfo<$UsersTable, User> {
|
|||
List<GeneratedColumn> get $columns =>
|
||||
[id, name, isAwesome, profilePicture, creationTime];
|
||||
@override
|
||||
String get aliasedName => _alias ?? 'users';
|
||||
String get aliasedName => _alias ?? actualTableName;
|
||||
@override
|
||||
String get actualTableName => 'users';
|
||||
String get actualTableName => $name;
|
||||
static const String $name = 'users';
|
||||
@override
|
||||
VerificationContext validateIntegrity(Insertable<User> instance,
|
||||
{bool isInserting = false}) {
|
||||
|
@ -935,9 +938,10 @@ class $SharedTodosTable extends SharedTodos
|
|||
@override
|
||||
List<GeneratedColumn> get $columns => [todo, user];
|
||||
@override
|
||||
String get aliasedName => _alias ?? 'shared_todos';
|
||||
String get aliasedName => _alias ?? actualTableName;
|
||||
@override
|
||||
String get actualTableName => 'shared_todos';
|
||||
String get actualTableName => $name;
|
||||
static const String $name = 'shared_todos';
|
||||
@override
|
||||
VerificationContext validateIntegrity(Insertable<SharedTodo> instance,
|
||||
{bool isInserting = false}) {
|
||||
|
@ -1139,9 +1143,10 @@ class $TableWithoutPKTable extends TableWithoutPK
|
|||
List<GeneratedColumn> get $columns =>
|
||||
[notReallyAnId, someFloat, webSafeInt, custom];
|
||||
@override
|
||||
String get aliasedName => _alias ?? 'table_without_p_k';
|
||||
String get aliasedName => _alias ?? actualTableName;
|
||||
@override
|
||||
String get actualTableName => 'table_without_p_k';
|
||||
String get actualTableName => $name;
|
||||
static const String $name = 'table_without_p_k';
|
||||
@override
|
||||
VerificationContext validateIntegrity(Insertable<CustomRowClass> instance,
|
||||
{bool isInserting = false}) {
|
||||
|
@ -1320,9 +1325,10 @@ class $PureDefaultsTable extends PureDefaults
|
|||
@override
|
||||
List<GeneratedColumn> get $columns => [txt];
|
||||
@override
|
||||
String get aliasedName => _alias ?? 'pure_defaults';
|
||||
String get aliasedName => _alias ?? actualTableName;
|
||||
@override
|
||||
String get actualTableName => 'pure_defaults';
|
||||
String get actualTableName => $name;
|
||||
static const String $name = 'pure_defaults';
|
||||
@override
|
||||
VerificationContext validateIntegrity(Insertable<PureDefault> instance,
|
||||
{bool isInserting = false}) {
|
||||
|
|
|
@ -26,9 +26,10 @@ class $_SomeTableTable extends _SomeTable
|
|||
@override
|
||||
List<GeneratedColumn> get $columns => [id, name];
|
||||
@override
|
||||
String get aliasedName => _alias ?? 'some_table';
|
||||
String get aliasedName => _alias ?? actualTableName;
|
||||
@override
|
||||
String get actualTableName => 'some_table';
|
||||
String get actualTableName => $name;
|
||||
static const String $name = 'some_table';
|
||||
@override
|
||||
VerificationContext validateIntegrity(Insertable<_SomeTableData> instance,
|
||||
{bool isInserting = false}) {
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
## 2.12.0-dev
|
||||
|
||||
- Adds the static getter `$name` to generated table classes.
|
||||
|
||||
## 2.11.2
|
||||
|
||||
- Follow `export` directives when looking for table imports.
|
||||
|
|
|
@ -407,9 +407,9 @@ class TableWriter extends TableOrViewWriter {
|
|||
writeGetColumnsOverride();
|
||||
buffer
|
||||
..write('@override\nString get aliasedName => '
|
||||
'_alias ?? \'${table.id.name}\';\n')
|
||||
..write(
|
||||
'@override\n String get actualTableName => \'${table.id.name}\';\n');
|
||||
'_alias ?? actualTableName;\n')
|
||||
..write('@override\n String get actualTableName => \$name;\n')
|
||||
..write('static const String \$name = \'${table.id.name}\';\n');
|
||||
|
||||
_writeValidityCheckMethod();
|
||||
_writePrimaryKeyOverride();
|
||||
|
|
|
@ -42,9 +42,10 @@ class $UsersTable extends Users with TableInfo<$UsersTable, User> {
|
|||
@override
|
||||
List<GeneratedColumn> get $columns => [id, name, birthday, nextUser];
|
||||
@override
|
||||
String get aliasedName => _alias ?? 'users';
|
||||
String get aliasedName => _alias ?? actualTableName;
|
||||
@override
|
||||
String get actualTableName => 'users';
|
||||
String get actualTableName => $name;
|
||||
static const String $name = 'users';
|
||||
@override
|
||||
VerificationContext validateIntegrity(Insertable<User> instance,
|
||||
{bool isInserting = false}) {
|
||||
|
@ -292,9 +293,10 @@ class Groups extends Table with TableInfo<Groups, Group> {
|
|||
@override
|
||||
List<GeneratedColumn> get $columns => [id, title, deleted, owner];
|
||||
@override
|
||||
String get aliasedName => _alias ?? 'groups';
|
||||
String get aliasedName => _alias ?? actualTableName;
|
||||
@override
|
||||
String get actualTableName => 'groups';
|
||||
String get actualTableName => $name;
|
||||
static const String $name = 'groups';
|
||||
@override
|
||||
VerificationContext validateIntegrity(Insertable<Group> instance,
|
||||
{bool isInserting = false}) {
|
||||
|
@ -542,9 +544,10 @@ class Notes extends Table
|
|||
@override
|
||||
List<GeneratedColumn> get $columns => [title, content, searchTerms];
|
||||
@override
|
||||
String get aliasedName => _alias ?? 'notes';
|
||||
String get aliasedName => _alias ?? actualTableName;
|
||||
@override
|
||||
String get actualTableName => 'notes';
|
||||
String get actualTableName => $name;
|
||||
static const String $name = 'notes';
|
||||
@override
|
||||
VerificationContext validateIntegrity(Insertable<Note> instance,
|
||||
{bool isInserting = false}) {
|
||||
|
|
|
@ -30,9 +30,10 @@ class Posts extends i0.Table with i0.TableInfo<Posts, i1.Post> {
|
|||
@override
|
||||
List<i0.GeneratedColumn> get $columns => [id, author, content];
|
||||
@override
|
||||
String get aliasedName => _alias ?? 'posts';
|
||||
String get aliasedName => _alias ?? actualTableName;
|
||||
@override
|
||||
String get actualTableName => 'posts';
|
||||
String get actualTableName => $name;
|
||||
static const String $name = 'posts';
|
||||
@override
|
||||
i0.VerificationContext validateIntegrity(i0.Insertable<i1.Post> instance,
|
||||
{bool isInserting = false}) {
|
||||
|
@ -236,9 +237,10 @@ class Likes extends i0.Table with i0.TableInfo<Likes, i1.Like> {
|
|||
@override
|
||||
List<i0.GeneratedColumn> get $columns => [post, likedBy];
|
||||
@override
|
||||
String get aliasedName => _alias ?? 'likes';
|
||||
String get aliasedName => _alias ?? actualTableName;
|
||||
@override
|
||||
String get actualTableName => 'likes';
|
||||
String get actualTableName => $name;
|
||||
static const String $name = 'likes';
|
||||
@override
|
||||
i0.VerificationContext validateIntegrity(i0.Insertable<i1.Like> instance,
|
||||
{bool isInserting = false}) {
|
||||
|
|
|
@ -29,9 +29,10 @@ class SearchInPosts extends i0.Table
|
|||
@override
|
||||
List<i0.GeneratedColumn> get $columns => [author, content];
|
||||
@override
|
||||
String get aliasedName => _alias ?? 'search_in_posts';
|
||||
String get aliasedName => _alias ?? actualTableName;
|
||||
@override
|
||||
String get actualTableName => 'search_in_posts';
|
||||
String get actualTableName => $name;
|
||||
static const String $name = 'search_in_posts';
|
||||
@override
|
||||
i0.VerificationContext validateIntegrity(
|
||||
i0.Insertable<i1.SearchInPost> instance,
|
||||
|
|
|
@ -48,9 +48,10 @@ class Users extends i0.Table with i0.TableInfo<Users, i1.User> {
|
|||
List<i0.GeneratedColumn> get $columns =>
|
||||
[id, name, biography, preferences, profilePicture];
|
||||
@override
|
||||
String get aliasedName => _alias ?? 'users';
|
||||
String get aliasedName => _alias ?? actualTableName;
|
||||
@override
|
||||
String get actualTableName => 'users';
|
||||
String get actualTableName => $name;
|
||||
static const String $name = 'users';
|
||||
@override
|
||||
i0.VerificationContext validateIntegrity(i0.Insertable<i1.User> instance,
|
||||
{bool isInserting = false}) {
|
||||
|
@ -338,9 +339,10 @@ class Follows extends i0.Table with i0.TableInfo<Follows, i1.Follow> {
|
|||
@override
|
||||
List<i0.GeneratedColumn> get $columns => [followed, follower];
|
||||
@override
|
||||
String get aliasedName => _alias ?? 'follows';
|
||||
String get aliasedName => _alias ?? actualTableName;
|
||||
@override
|
||||
String get actualTableName => 'follows';
|
||||
String get actualTableName => $name;
|
||||
static const String $name = 'follows';
|
||||
@override
|
||||
i0.VerificationContext validateIntegrity(i0.Insertable<i1.Follow> instance,
|
||||
{bool isInserting = false}) {
|
||||
|
|
|
@ -23,9 +23,10 @@ class Entries extends Table with TableInfo<Entries, Entrie> {
|
|||
@override
|
||||
List<GeneratedColumn> get $columns => [id, value];
|
||||
@override
|
||||
String get aliasedName => _alias ?? 'entries';
|
||||
String get aliasedName => _alias ?? actualTableName;
|
||||
@override
|
||||
String get actualTableName => 'entries';
|
||||
String get actualTableName => $name;
|
||||
static const String $name = 'entries';
|
||||
@override
|
||||
VerificationContext validateIntegrity(Insertable<Entrie> instance,
|
||||
{bool isInserting = false}) {
|
||||
|
|
|
@ -22,9 +22,10 @@ class Users extends Table with TableInfo<Users, User> {
|
|||
@override
|
||||
List<GeneratedColumn> get $columns => [id, name];
|
||||
@override
|
||||
String get aliasedName => _alias ?? 'users';
|
||||
String get aliasedName => _alias ?? actualTableName;
|
||||
@override
|
||||
String get actualTableName => 'users';
|
||||
String get actualTableName => $name;
|
||||
static const String $name = 'users';
|
||||
@override
|
||||
VerificationContext validateIntegrity(Insertable<User> instance,
|
||||
{bool isInserting = false}) {
|
||||
|
|
|
@ -22,9 +22,10 @@ class $KeyValuesTable extends KeyValues
|
|||
@override
|
||||
List<GeneratedColumn> get $columns => [key, value];
|
||||
@override
|
||||
String get aliasedName => _alias ?? 'key_values';
|
||||
String get aliasedName => _alias ?? actualTableName;
|
||||
@override
|
||||
String get actualTableName => 'key_values';
|
||||
String get actualTableName => $name;
|
||||
static const String $name = 'key_values';
|
||||
@override
|
||||
VerificationContext validateIntegrity(Insertable<KeyValue> instance,
|
||||
{bool isInserting = false}) {
|
||||
|
|
|
@ -48,9 +48,10 @@ class $UsersTable extends Users with TableInfo<$UsersTable, User> {
|
|||
List<GeneratedColumn> get $columns =>
|
||||
[id, name, birthDate, profilePicture, preferences];
|
||||
@override
|
||||
String get aliasedName => _alias ?? 'users';
|
||||
String get aliasedName => _alias ?? actualTableName;
|
||||
@override
|
||||
String get actualTableName => 'users';
|
||||
String get actualTableName => $name;
|
||||
static const String $name = 'users';
|
||||
@override
|
||||
VerificationContext validateIntegrity(Insertable<User> instance,
|
||||
{bool isInserting = false}) {
|
||||
|
@ -347,9 +348,10 @@ class $FriendshipsTable extends Friendships
|
|||
List<GeneratedColumn> get $columns =>
|
||||
[firstUser, secondUser, reallyGoodFriends];
|
||||
@override
|
||||
String get aliasedName => _alias ?? 'friendships';
|
||||
String get aliasedName => _alias ?? actualTableName;
|
||||
@override
|
||||
String get actualTableName => 'friendships';
|
||||
String get actualTableName => $name;
|
||||
static const String $name = 'friendships';
|
||||
@override
|
||||
VerificationContext validateIntegrity(Insertable<Friendship> instance,
|
||||
{bool isInserting = false}) {
|
||||
|
|
|
@ -20,9 +20,10 @@ class $FoosTable extends Foos with TableInfo<$FoosTable, Foo> {
|
|||
@override
|
||||
List<GeneratedColumn> get $columns => [id];
|
||||
@override
|
||||
String get aliasedName => _alias ?? 'foos';
|
||||
String get aliasedName => _alias ?? actualTableName;
|
||||
@override
|
||||
String get actualTableName => 'foos';
|
||||
String get actualTableName => $name;
|
||||
static const String $name = 'foos';
|
||||
@override
|
||||
VerificationContext validateIntegrity(Insertable<Foo> instance,
|
||||
{bool isInserting = false}) {
|
||||
|
@ -157,9 +158,10 @@ class $BarsTable extends Bars with TableInfo<$BarsTable, Bar> {
|
|||
@override
|
||||
List<GeneratedColumn> get $columns => [id];
|
||||
@override
|
||||
String get aliasedName => _alias ?? 'bars';
|
||||
String get aliasedName => _alias ?? actualTableName;
|
||||
@override
|
||||
String get actualTableName => 'bars';
|
||||
String get actualTableName => $name;
|
||||
static const String $name = 'bars';
|
||||
@override
|
||||
VerificationContext validateIntegrity(Insertable<Bar> instance,
|
||||
{bool isInserting = false}) {
|
||||
|
|
|
@ -27,9 +27,10 @@ class $TestTableTable extends TestTable
|
|||
@override
|
||||
List<GeneratedColumn> get $columns => [id, content];
|
||||
@override
|
||||
String get aliasedName => _alias ?? 'test_table';
|
||||
String get aliasedName => _alias ?? actualTableName;
|
||||
@override
|
||||
String get actualTableName => 'test_table';
|
||||
String get actualTableName => $name;
|
||||
static const String $name = 'test_table';
|
||||
@override
|
||||
VerificationContext validateIntegrity(Insertable<TestTableData> instance,
|
||||
{bool isInserting = false}) {
|
||||
|
|
Loading…
Reference in New Issue