Skip to content

Commit aa3d9c5

Browse files
authored
fix: Handle enums when one of its values is named 'name' (serverpod#3151)
1 parent 8b3ac1b commit aa3d9c5

File tree

45 files changed

+2810
-2423
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+2810
-2423
lines changed

modules/serverpod_auth/serverpod_auth_client/lib/src/protocol/authentication_fail_reason.dart

+5-5
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ enum AuthenticationFailReason implements _i1.SerializableModel {
2222
static AuthenticationFailReason fromJson(int index) {
2323
switch (index) {
2424
case 0:
25-
return invalidCredentials;
25+
return AuthenticationFailReason.invalidCredentials;
2626
case 1:
27-
return userCreationDenied;
27+
return AuthenticationFailReason.userCreationDenied;
2828
case 2:
29-
return internalError;
29+
return AuthenticationFailReason.internalError;
3030
case 3:
31-
return tooManyFailedAttempts;
31+
return AuthenticationFailReason.tooManyFailedAttempts;
3232
case 4:
33-
return blocked;
33+
return AuthenticationFailReason.blocked;
3434
default:
3535
throw ArgumentError(
3636
'Value "$index" cannot be converted to "AuthenticationFailReason"');

modules/serverpod_auth/serverpod_auth_server/lib/src/generated/authentication_fail_reason.dart

+5-5
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ enum AuthenticationFailReason implements _i1.SerializableModel {
2222
static AuthenticationFailReason fromJson(int index) {
2323
switch (index) {
2424
case 0:
25-
return invalidCredentials;
25+
return AuthenticationFailReason.invalidCredentials;
2626
case 1:
27-
return userCreationDenied;
27+
return AuthenticationFailReason.userCreationDenied;
2828
case 2:
29-
return internalError;
29+
return AuthenticationFailReason.internalError;
3030
case 3:
31-
return tooManyFailedAttempts;
31+
return AuthenticationFailReason.tooManyFailedAttempts;
3232
case 4:
33-
return blocked;
33+
return AuthenticationFailReason.blocked;
3434
default:
3535
throw ArgumentError(
3636
'Value "$index" cannot be converted to "AuthenticationFailReason"');

packages/serverpod/lib/src/generated/database/column_type.dart

+10-10
Original file line numberDiff line numberDiff line change
@@ -48,25 +48,25 @@ enum ColumnType implements _i1.SerializableModel {
4848
static ColumnType fromJson(int index) {
4949
switch (index) {
5050
case 0:
51-
return text;
51+
return ColumnType.text;
5252
case 1:
53-
return boolean;
53+
return ColumnType.boolean;
5454
case 2:
55-
return integer;
55+
return ColumnType.integer;
5656
case 3:
57-
return doublePrecision;
57+
return ColumnType.doublePrecision;
5858
case 4:
59-
return timestampWithoutTimeZone;
59+
return ColumnType.timestampWithoutTimeZone;
6060
case 5:
61-
return bytea;
61+
return ColumnType.bytea;
6262
case 6:
63-
return bigint;
63+
return ColumnType.bigint;
6464
case 7:
65-
return uuid;
65+
return ColumnType.uuid;
6666
case 8:
67-
return json;
67+
return ColumnType.json;
6868
case 9:
69-
return unknown;
69+
return ColumnType.unknown;
7070
default:
7171
throw ArgumentError(
7272
'Value "$index" cannot be converted to "ColumnType"');

packages/serverpod/lib/src/generated/database/database_migration_action_type.dart

+4-4
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ enum DatabaseMigrationActionType implements _i1.SerializableModel {
2020
static DatabaseMigrationActionType fromJson(String name) {
2121
switch (name) {
2222
case 'createTable':
23-
return createTable;
23+
return DatabaseMigrationActionType.createTable;
2424
case 'createTableIfNotExists':
25-
return createTableIfNotExists;
25+
return DatabaseMigrationActionType.createTableIfNotExists;
2626
case 'deleteTable':
27-
return deleteTable;
27+
return DatabaseMigrationActionType.deleteTable;
2828
case 'alterTable':
29-
return alterTable;
29+
return DatabaseMigrationActionType.alterTable;
3030
default:
3131
throw ArgumentError(
3232
'Value "$name" cannot be converted to "DatabaseMigrationActionType"');

packages/serverpod/lib/src/generated/database/database_migration_warning_type.dart

+4-4
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ enum DatabaseMigrationWarningType implements _i1.SerializableModel {
2020
static DatabaseMigrationWarningType fromJson(String name) {
2121
switch (name) {
2222
case 'tableDropped':
23-
return tableDropped;
23+
return DatabaseMigrationWarningType.tableDropped;
2424
case 'columnDropped':
25-
return columnDropped;
25+
return DatabaseMigrationWarningType.columnDropped;
2626
case 'notNullAdded':
27-
return notNullAdded;
27+
return DatabaseMigrationWarningType.notNullAdded;
2828
case 'uniqueIndexCreated':
29-
return uniqueIndexCreated;
29+
return DatabaseMigrationWarningType.uniqueIndexCreated;
3030
default:
3131
throw ArgumentError(
3232
'Value "$name" cannot be converted to "DatabaseMigrationWarningType"');

packages/serverpod/lib/src/generated/database/enum_serialization.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ enum EnumSerialization implements _i1.SerializableModel {
1818
static EnumSerialization fromJson(int index) {
1919
switch (index) {
2020
case 0:
21-
return byName;
21+
return EnumSerialization.byName;
2222
case 1:
23-
return byIndex;
23+
return EnumSerialization.byIndex;
2424
default:
2525
throw ArgumentError(
2626
'Value "$index" cannot be converted to "EnumSerialization"');

packages/serverpod/lib/src/generated/database/filter/filter_constraint_type.dart

+14-14
Original file line numberDiff line numberDiff line change
@@ -30,33 +30,33 @@ enum FilterConstraintType implements _i1.SerializableModel {
3030
static FilterConstraintType fromJson(int index) {
3131
switch (index) {
3232
case 0:
33-
return equals;
33+
return FilterConstraintType.equals;
3434
case 1:
35-
return notEquals;
35+
return FilterConstraintType.notEquals;
3636
case 2:
37-
return like;
37+
return FilterConstraintType.like;
3838
case 3:
39-
return iLike;
39+
return FilterConstraintType.iLike;
4040
case 4:
41-
return notLike;
41+
return FilterConstraintType.notLike;
4242
case 5:
43-
return notILike;
43+
return FilterConstraintType.notILike;
4444
case 6:
45-
return lessThan;
45+
return FilterConstraintType.lessThan;
4646
case 7:
47-
return lessThanOrEquals;
47+
return FilterConstraintType.lessThanOrEquals;
4848
case 8:
49-
return greaterThan;
49+
return FilterConstraintType.greaterThan;
5050
case 9:
51-
return greaterThanOrEquals;
51+
return FilterConstraintType.greaterThanOrEquals;
5252
case 10:
53-
return between;
53+
return FilterConstraintType.between;
5454
case 11:
55-
return inThePast;
55+
return FilterConstraintType.inThePast;
5656
case 12:
57-
return isNull;
57+
return FilterConstraintType.isNull;
5858
case 13:
59-
return isNotNull;
59+
return FilterConstraintType.isNotNull;
6060
default:
6161
throw ArgumentError(
6262
'Value "$index" cannot be converted to "FilterConstraintType"');

packages/serverpod/lib/src/generated/database/foreign_key_action.dart

+5-5
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@ enum ForeignKeyAction implements _i1.SerializableModel {
3939
static ForeignKeyAction fromJson(int index) {
4040
switch (index) {
4141
case 0:
42-
return setNull;
42+
return ForeignKeyAction.setNull;
4343
case 1:
44-
return setDefault;
44+
return ForeignKeyAction.setDefault;
4545
case 2:
46-
return restrict;
46+
return ForeignKeyAction.restrict;
4747
case 3:
48-
return noAction;
48+
return ForeignKeyAction.noAction;
4949
case 4:
50-
return cascade;
50+
return ForeignKeyAction.cascade;
5151
default:
5252
throw ArgumentError(
5353
'Value "$index" cannot be converted to "ForeignKeyAction"');

packages/serverpod/lib/src/generated/database/foreign_key_match_type.dart

+3-3
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ enum ForeignKeyMatchType implements _i1.SerializableModel {
2828
static ForeignKeyMatchType fromJson(int index) {
2929
switch (index) {
3030
case 0:
31-
return full;
31+
return ForeignKeyMatchType.full;
3232
case 1:
33-
return partial;
33+
return ForeignKeyMatchType.partial;
3434
case 2:
35-
return simple;
35+
return ForeignKeyMatchType.simple;
3636
default:
3737
throw ArgumentError(
3838
'Value "$index" cannot be converted to "ForeignKeyMatchType"');

packages/serverpod/lib/src/generated/database/index_element_definition_type.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ enum IndexElementDefinitionType implements _i1.SerializableModel {
2525
static IndexElementDefinitionType fromJson(int index) {
2626
switch (index) {
2727
case 0:
28-
return column;
28+
return IndexElementDefinitionType.column;
2929
case 1:
30-
return expression;
30+
return IndexElementDefinitionType.expression;
3131
default:
3232
throw ArgumentError(
3333
'Value "$index" cannot be converted to "IndexElementDefinitionType"');

packages/serverpod/lib/src/generated/log_level.dart

+5-5
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ enum LogLevel implements _i1.SerializableModel {
2222
static LogLevel fromJson(int index) {
2323
switch (index) {
2424
case 0:
25-
return debug;
25+
return LogLevel.debug;
2626
case 1:
27-
return info;
27+
return LogLevel.info;
2828
case 2:
29-
return warning;
29+
return LogLevel.warning;
3030
case 3:
31-
return error;
31+
return LogLevel.error;
3232
case 4:
33-
return fatal;
33+
return LogLevel.fatal;
3434
default:
3535
throw ArgumentError('Value "$index" cannot be converted to "LogLevel"');
3636
}

packages/serverpod_service_client/lib/src/protocol/database/column_type.dart

+10-10
Original file line numberDiff line numberDiff line change
@@ -48,25 +48,25 @@ enum ColumnType implements _i1.SerializableModel {
4848
static ColumnType fromJson(int index) {
4949
switch (index) {
5050
case 0:
51-
return text;
51+
return ColumnType.text;
5252
case 1:
53-
return boolean;
53+
return ColumnType.boolean;
5454
case 2:
55-
return integer;
55+
return ColumnType.integer;
5656
case 3:
57-
return doublePrecision;
57+
return ColumnType.doublePrecision;
5858
case 4:
59-
return timestampWithoutTimeZone;
59+
return ColumnType.timestampWithoutTimeZone;
6060
case 5:
61-
return bytea;
61+
return ColumnType.bytea;
6262
case 6:
63-
return bigint;
63+
return ColumnType.bigint;
6464
case 7:
65-
return uuid;
65+
return ColumnType.uuid;
6666
case 8:
67-
return json;
67+
return ColumnType.json;
6868
case 9:
69-
return unknown;
69+
return ColumnType.unknown;
7070
default:
7171
throw ArgumentError(
7272
'Value "$index" cannot be converted to "ColumnType"');

packages/serverpod_service_client/lib/src/protocol/database/database_migration_action_type.dart

+4-4
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ enum DatabaseMigrationActionType implements _i1.SerializableModel {
2020
static DatabaseMigrationActionType fromJson(String name) {
2121
switch (name) {
2222
case 'createTable':
23-
return createTable;
23+
return DatabaseMigrationActionType.createTable;
2424
case 'createTableIfNotExists':
25-
return createTableIfNotExists;
25+
return DatabaseMigrationActionType.createTableIfNotExists;
2626
case 'deleteTable':
27-
return deleteTable;
27+
return DatabaseMigrationActionType.deleteTable;
2828
case 'alterTable':
29-
return alterTable;
29+
return DatabaseMigrationActionType.alterTable;
3030
default:
3131
throw ArgumentError(
3232
'Value "$name" cannot be converted to "DatabaseMigrationActionType"');

packages/serverpod_service_client/lib/src/protocol/database/database_migration_warning_type.dart

+4-4
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ enum DatabaseMigrationWarningType implements _i1.SerializableModel {
2020
static DatabaseMigrationWarningType fromJson(String name) {
2121
switch (name) {
2222
case 'tableDropped':
23-
return tableDropped;
23+
return DatabaseMigrationWarningType.tableDropped;
2424
case 'columnDropped':
25-
return columnDropped;
25+
return DatabaseMigrationWarningType.columnDropped;
2626
case 'notNullAdded':
27-
return notNullAdded;
27+
return DatabaseMigrationWarningType.notNullAdded;
2828
case 'uniqueIndexCreated':
29-
return uniqueIndexCreated;
29+
return DatabaseMigrationWarningType.uniqueIndexCreated;
3030
default:
3131
throw ArgumentError(
3232
'Value "$name" cannot be converted to "DatabaseMigrationWarningType"');

packages/serverpod_service_client/lib/src/protocol/database/enum_serialization.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ enum EnumSerialization implements _i1.SerializableModel {
1818
static EnumSerialization fromJson(int index) {
1919
switch (index) {
2020
case 0:
21-
return byName;
21+
return EnumSerialization.byName;
2222
case 1:
23-
return byIndex;
23+
return EnumSerialization.byIndex;
2424
default:
2525
throw ArgumentError(
2626
'Value "$index" cannot be converted to "EnumSerialization"');

packages/serverpod_service_client/lib/src/protocol/database/filter/filter_constraint_type.dart

+14-14
Original file line numberDiff line numberDiff line change
@@ -30,33 +30,33 @@ enum FilterConstraintType implements _i1.SerializableModel {
3030
static FilterConstraintType fromJson(int index) {
3131
switch (index) {
3232
case 0:
33-
return equals;
33+
return FilterConstraintType.equals;
3434
case 1:
35-
return notEquals;
35+
return FilterConstraintType.notEquals;
3636
case 2:
37-
return like;
37+
return FilterConstraintType.like;
3838
case 3:
39-
return iLike;
39+
return FilterConstraintType.iLike;
4040
case 4:
41-
return notLike;
41+
return FilterConstraintType.notLike;
4242
case 5:
43-
return notILike;
43+
return FilterConstraintType.notILike;
4444
case 6:
45-
return lessThan;
45+
return FilterConstraintType.lessThan;
4646
case 7:
47-
return lessThanOrEquals;
47+
return FilterConstraintType.lessThanOrEquals;
4848
case 8:
49-
return greaterThan;
49+
return FilterConstraintType.greaterThan;
5050
case 9:
51-
return greaterThanOrEquals;
51+
return FilterConstraintType.greaterThanOrEquals;
5252
case 10:
53-
return between;
53+
return FilterConstraintType.between;
5454
case 11:
55-
return inThePast;
55+
return FilterConstraintType.inThePast;
5656
case 12:
57-
return isNull;
57+
return FilterConstraintType.isNull;
5858
case 13:
59-
return isNotNull;
59+
return FilterConstraintType.isNotNull;
6060
default:
6161
throw ArgumentError(
6262
'Value "$index" cannot be converted to "FilterConstraintType"');

packages/serverpod_service_client/lib/src/protocol/database/foreign_key_action.dart

+5-5
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@ enum ForeignKeyAction implements _i1.SerializableModel {
3939
static ForeignKeyAction fromJson(int index) {
4040
switch (index) {
4141
case 0:
42-
return setNull;
42+
return ForeignKeyAction.setNull;
4343
case 1:
44-
return setDefault;
44+
return ForeignKeyAction.setDefault;
4545
case 2:
46-
return restrict;
46+
return ForeignKeyAction.restrict;
4747
case 3:
48-
return noAction;
48+
return ForeignKeyAction.noAction;
4949
case 4:
50-
return cascade;
50+
return ForeignKeyAction.cascade;
5151
default:
5252
throw ArgumentError(
5353
'Value "$index" cannot be converted to "ForeignKeyAction"');

0 commit comments

Comments
 (0)