Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
using System.Data.Common;
using System.Linq;
using FirebirdSql.Data.FirebirdClient;
using FirebirdSql.Data.Services;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Scaffolding;
Expand Down Expand Up @@ -178,7 +179,7 @@ ELSE F.RDB$FIELD_SUB_TYPE
ELSE 'RDB$FIELD_TYPE: ' || F.RDB$FIELD_TYPE || '?'
END as STORE_TYPE,
F.rdb$description as COLUMN_COMMENT,
COALESCE(RF.RDB$IDENTITY_TYPE, 0) as AUTO_GENERATED,
COALESCE({1}, 0) as AUTO_GENERATED,
ch.RDB$CHARACTER_SET_NAME as CHARACTER_SET_NAME
FROM
RDB$RELATION_FIELDS RF
Expand All @@ -192,11 +193,20 @@ ORDER BY

private void GetColumns(DbConnection connection, IReadOnlyList<DatabaseTable> tables, Func<string, string, bool> tableFilter)
{
var identity_type = "null";

if (connection.State == ConnectionState.Open)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At this point connection is known to be open.

{
var serverVersion = FbServerProperties.ParseServerVersion(connection.ServerVersion);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would put this into DatabaseModel Create(DbConnection connection, DatabaseModelFactoryOptions options) method and create a property for it.

if (serverVersion.Major >= 3)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Store MajorVersionNumber directly, to make it easier for future.

identity_type = "rf.RDB$IDENTITY_TYPE";
}

foreach (var table in tables)
{
using (var command = connection.CreateCommand())
{
command.CommandText = string.Format(GetColumnsQuery, table.Name);
command.CommandText = string.Format(GetColumnsQuery, table.Name, identity_type);
using (var reader = command.ExecuteReader())
{
while (reader.Read())
Expand Down