Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit a8f6b3d

Browse files
madalenomythz
authored andcommitted
More on FireBird4. (#629)
* Added support for FireBird 4. Fixed DoesTableExist() that was returning null if table didn't exist. Added support for the new FireBird 4 Identity autoincrement columns. Added some tests for the new FirdBird 4 features. Changed behavior of AutoIncrement fields to use Identity instead of Sequences when using the new FireBird 4 dialect. Work in progress,,,, * Fixed PopulateReturnValues() when the primary key is a Guid (attribute AutoId). It tried to convert the value to an Int64. Fixed PrepareParameterizedInsertStatement() in Firebird4OrmLiteDialectProvider to generate the insert sql with GEN_UUID() for the fields with AutoId attribute when using the FirebirdCompactGuidConverter. Fixed ShouldSkipInsert() in FirebirdOrmLiteDialectProvider to not skip fields with AutoId attribute. Added some tests for models with AutId attributes. * Updated reserved words in FireBird4 dialect provider. Changed the autoincrement definition from "by default" to "always" since there is no easy way to generate the insert sql based on object values. To use "By Default" the generated insert sql should not contain the Id field name if the Id value is null. Updated FirebirdClient package to 6.6.0. Changed obsolete method SelectFmt in Schema.cs.
1 parent 4b6489e commit a8f6b3d

File tree

3 files changed

+30
-13
lines changed

3 files changed

+30
-13
lines changed

src/ServiceStack.OrmLite.Firebird/FbSchema/Schema.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@ public Schema()
2727
Init();
2828
}
2929

30-
public List<Table> Tables => Connection.SelectFmt<Table>(sqlTables);
30+
public List<Table> Tables => Connection.Select<Table>(sqlTables);
3131

3232
public Table GetTable(string name)
3333
{
3434

3535
string sql = sqlTables +
3636
$" AND a.rdb$relation_name ='{name}' ";
3737

38-
var query = Connection.SelectFmt<Table>(sql);
38+
var query = Connection.Select<Table>(sql);
3939
return query.FirstOrDefault();
4040
}
4141

@@ -46,14 +46,14 @@ public List<Column> GetColumns(string tableName)
4646
string.IsNullOrEmpty(tableName) ? "idx.rdb$relation_name" : $"'{tableName}'",
4747
string.IsNullOrEmpty(tableName) ? "r.rdb$relation_name" : $"'{tableName}'");
4848

49-
List<Column> columns =Connection.SelectFmt<Column>(sql);
49+
List<Column> columns =Connection.Select<Column>(sql);
5050

51-
List<Generador> gens = Connection.SelectFmt<Generador>(sqlGenerator.ToString());
51+
List<Generador> gens = Connection.Select<Generador>(sqlGenerator.ToString());
5252

5353
sql = string.Format(sqlFieldGenerator.ToString(),
5454
string.IsNullOrEmpty(tableName) ? "TRIGGERS.RDB$RELATION_NAME" : $"'{tableName}'");
5555

56-
List<FieldGenerator> fg = Connection.SelectFmt<FieldGenerator>(sql);
56+
List<FieldGenerator> fg = Connection.Select<FieldGenerator>(sql);
5757

5858
foreach (var record in columns)
5959
{
@@ -87,11 +87,11 @@ public Procedure GetProcedure(string name)
8787
string sql= sqlProcedures.ToString() +
8888
$"WHERE b.rdb$procedure_name ='{name}'";
8989

90-
var query = Connection.SelectFmt<Procedure>(sql);
90+
var query = Connection.Select<Procedure>(sql);
9191
return query.FirstOrDefault();
9292
}
9393

94-
public List<Procedure> Procedures => Connection.SelectFmt<Procedure>(sqlProcedures.ToString());
94+
public List<Procedure> Procedures => Connection.Select<Procedure>(sqlProcedures.ToString());
9595

9696
public List<Parameter> GetParameters(Procedure procedure)
9797
{
@@ -104,7 +104,7 @@ public List<Parameter> GetParameters(string procedureName)
104104
string sql = string.Format(sqlParameters.ToString(),
105105
string.IsNullOrEmpty(procedureName) ? "a.rdb$procedure_name" : $"'{procedureName}'");
106106

107-
return Connection.SelectFmt<Parameter>(sql);
107+
return Connection.Select<Parameter>(sql);
108108
}
109109

110110
private void Init()

src/ServiceStack.OrmLite.Firebird/Firebird4OrmLiteDialectProvider.cs

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,26 @@ public class Firebird4OrmLiteDialectProvider : FirebirdOrmLiteDialectProvider
1616
{
1717
private readonly bool usesCompactGuid;
1818

19-
public static List<string> RESERVED = new List<string>(new[] {
20-
"USER","ORDER","PASSWORD", "ACTIVE","LEFT","DOUBLE", "FLOAT", "DECIMAL","STRING", "DATE","DATETIME", "TYPE","TIMESTAMP",
21-
"INDEX","UNIQUE", "PRIMARY", "KEY", "ALTER", "DROP", "CREATE", "DELETE", "VALUES", "FUNCTION", "INT", "LONG", "CHAR", "VALUE", "TIME"
19+
public new static List<string> RESERVED = new List<string>(new[] {
20+
"ADD","ADMIN","ALL","ALTER","AND","ANY","AS","AT","AVG","BEGIN","BETWEEN","BIGINT","BIT_LENGTH","BLOB","BOTH","BY","CASE","CAST",
21+
"CHAR","CHAR_LENGTH","CHARACTER","CHARACTER_LENGTH","CHECK","CLOSE","COLLATE","COLUMN","COMMIT","CONNECT","CONSTRAINT","COUNT","CREATE",
22+
"CROSS","CURRENT","CURRENT_CONNECTION","CURRENT_DATE","CURRENT_ROLE","CURRENT_TIME","CURRENT_TIMESTAMP","CURRENT_TRANSACTION","CURRENT_USER",
23+
"CURSOR","DATE","DAY","DEC","DECIMAL","DECLARE","DEFAULT","DELETE","DISCONNECT","DISTINCT","DOUBLE","DROP","ELSE","END","ESCAPE",
24+
"EXECUTE","EXISTS","EXTERNAL","EXTRACT","FETCH","FILTER","FLOAT","FOR","FOREIGN","FROM","FULL","FUNCTION","GDSCODE","GLOBAL","GRANT","GROUP",
25+
"HAVING","HOUR","IN","INDEX","INNER","INSENSITIVE","INSERT","INT","INTEGER","INTO","IS","JOIN","LEADING","LEFT","LIKE","LONG","LOWER","MAX",
26+
"MAXIMUM_SEGMENT","MERGE","MIN","MINUTE","MONTH","NATIONAL","NATURAL","NCHAR","NO","NOT","NULL","NUMERIC","OCTET_LENGTH","OF","ON","ONLY",
27+
"OPEN","OR","ORDER","OUTER","PARAMETER","PLAN","POSITION","POST_EVENT","PRECISION","PRIMARY","PROCEDURE","RDB$DB_KEY","REAL","RECORD_VERSION",
28+
"RECREATE","RECURSIVE","REFERENCES","RELEASE","RETURNING_VALUES","RETURNS","REVOKE","RIGHT","ROLLBACK","ROW_COUNT","ROWS","SAVEPOINT","SECOND",
29+
"SELECT","SENSITIVE","SET","SIMILAR","SMALLINT","SOME","SQLCODE","SQLSTATE","START","SUM","TABLE","THEN","TIME","TIMESTAMP","TO","TRAILING",
30+
"TRIGGER","TRIM","UNION","UNIQUE","UPDATE","UPPER","USER","USING","VALUE","VALUES","VARCHAR","VARIABLE","VARYING","VIEW","WHEN","WHERE","WHILE",
31+
"WITH","YEAR",
32+
"PASSWORD","ACTIVE","LEFT","DATETIME","TYPE","KEY",
33+
// new in FB3
34+
"INSERTING","UPDATING","DELETING","REGR_AVGX","SCROLL","CORR","REGR_AVGY","COVAR_POP","REGR_COUNT","STDDEV_POP",
35+
"COVAR_SAMP","REGR_INTERCEPT","STDDEV_SAMP","REGR_R2","TRUE","DETERMINISTIC","REGR_SLOPE","UNKNOWN","FALSE","REGR_SXX",
36+
"REGR_SXY","VAR_POP","OFFSET","REGR_SYY","VAR_SAMP","OVER","RETURN","RDB$RECORD_VERSION","ROW","BOOLEAN",
37+
// new in FB4
38+
"BINARY","VARBINARY","DECFLOAT"
2239
});
2340

2441
public new static Firebird4OrmLiteDialectProvider Instance = new Firebird4OrmLiteDialectProvider();
@@ -30,7 +47,7 @@ public Firebird4OrmLiteDialectProvider(bool compactGuid): base(compactGuid)
3047
usesCompactGuid = compactGuid;
3148

3249
// FB4 now has identity columns
33-
base.AutoIncrementDefinition = " GENERATED BY DEFAULT AS IDENTITY ";
50+
base.AutoIncrementDefinition = " GENERATED ALWAYS AS IDENTITY ";
3451
NamingStrategy = new Firebird4NamingStrategy();
3552

3653
base.RemoveConverter<bool>();

src/ServiceStack.OrmLite.Firebird/ServiceStack.OrmLite.Firebird.Core.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<ItemGroup>
1717
<ProjectReference Include="..\ServiceStack.OrmLite\ServiceStack.OrmLite.Core.csproj" />
1818
<PackageReference Include="ServiceStack.Common.Core" Version="$(Version)" />
19-
<PackageReference Include="FirebirdSql.Data.FirebirdClient" Version="6.5.0" />
19+
<PackageReference Include="FirebirdSql.Data.FirebirdClient" Version="6.6.0" />
2020
</ItemGroup>
2121

2222
</Project>

0 commit comments

Comments
 (0)