@@ -107,6 +107,54 @@ public async Task ReadsCorrectFieldType(string dataType)
107107 Assert . That ( column . StoreType , Is . EqualTo ( dataType ) ) ;
108108 }
109109
110+ [ Test ]
111+ public async Task ExpressionIndexDoesNotBreakScaffolding ( )
112+ {
113+ var tableName = "TEST_EXPR_IDX" ;
114+
115+ using var commandTable = Connection . CreateCommand ( ) ;
116+ commandTable . CommandText = $ "recreate table { tableName } (ID INTEGER NOT NULL, DATA VARCHAR(100))";
117+ await commandTable . ExecuteNonQueryAsync ( ) ;
118+
119+ using var commandIndex = Connection . CreateCommand ( ) ;
120+ commandIndex . CommandText = $ "create index IDX_EXPR on { tableName } computed by (upper(DATA))";
121+ await commandIndex . ExecuteNonQueryAsync ( ) ;
122+
123+ var modelFactory = GetModelFactory ( ) ;
124+ var model = modelFactory . Create ( Connection . ConnectionString , new DatabaseModelFactoryOptions ( new string [ ] { tableName } ) ) ;
125+ var table = model . Tables . Single ( x => x . Name == tableName ) ;
126+
127+ Assert . That ( table . Indexes , Has . None . Matches < Microsoft . EntityFrameworkCore . Scaffolding . Metadata . DatabaseIndex > ( x => x . Name == "IDX_EXPR" ) ) ;
128+ }
129+
130+ [ Test ]
131+ public async Task RegularIndexScaffoldedAlongsideExpressionIndex ( )
132+ {
133+ var tableName = "TEST_MIX_IDX" ;
134+
135+ using var commandTable = Connection . CreateCommand ( ) ;
136+ commandTable . CommandText = $ "recreate table { tableName } (ID INTEGER NOT NULL, DATA VARCHAR(100))";
137+ await commandTable . ExecuteNonQueryAsync ( ) ;
138+
139+ using var commandRegularIndex = Connection . CreateCommand ( ) ;
140+ commandRegularIndex . CommandText = $ "create index IDX_REGULAR on { tableName } (DATA)";
141+ await commandRegularIndex . ExecuteNonQueryAsync ( ) ;
142+
143+ using var commandExprIndex = Connection . CreateCommand ( ) ;
144+ commandExprIndex . CommandText = $ "create index IDX_EXPR_MIX on { tableName } computed by (upper(DATA))";
145+ await commandExprIndex . ExecuteNonQueryAsync ( ) ;
146+
147+ var modelFactory = GetModelFactory ( ) ;
148+ var model = modelFactory . Create ( Connection . ConnectionString , new DatabaseModelFactoryOptions ( new string [ ] { tableName } ) ) ;
149+ var table = model . Tables . Single ( x => x . Name == tableName ) ;
150+
151+ Assert . Multiple ( ( ) =>
152+ {
153+ Assert . That ( table . Indexes , Has . Some . Matches < Microsoft . EntityFrameworkCore . Scaffolding . Metadata . DatabaseIndex > ( x => x . Name == "IDX_REGULAR" ) ) ;
154+ Assert . That ( table . Indexes , Has . None . Matches < Microsoft . EntityFrameworkCore . Scaffolding . Metadata . DatabaseIndex > ( x => x . Name == "IDX_EXPR_MIX" ) ) ;
155+ } ) ;
156+ }
157+
110158 static IDatabaseModelFactory GetModelFactory ( )
111159 {
112160 return new FbDatabaseModelFactory ( ) ;
0 commit comments