Skip to content
Merged
Show file tree
Hide file tree
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
21 changes: 20 additions & 1 deletion Provider/src/FirebirdSql.Data.FirebirdClient/Schema/FbColumns.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,13 @@ protected override StringBuilder GetCommandText(string[] restrictions)
null AS COLLATION_CATALOG,
null AS COLLATION_SCHEMA,
coll.rdb$collation_name AS COLLATION_NAME,
rfr.rdb$description AS DESCRIPTION
rfr.rdb$description AS DESCRIPTION");
if (MajorVersionNumber >= 3)
{
sql.Append(@",
rfr.rdb$identity_type as IDENTITY_TYPE");
}
sql.Append(@"
FROM rdb$relation_fields rfr
LEFT JOIN rdb$fields fld ON rfr.rdb$field_source = fld.rdb$field_name
LEFT JOIN rdb$character_sets cs ON cs.rdb$character_set_id = fld.rdb$character_set_id
Expand Down Expand Up @@ -117,6 +123,10 @@ protected override DataTable ProcessResult(DataTable schema)
schema.BeginLoadData();
schema.Columns.Add("IS_NULLABLE", typeof(bool));
schema.Columns.Add("IS_ARRAY", typeof(bool));
if (MajorVersionNumber >= 3)
{
schema.Columns.Add("IS_IDENTITY", typeof(bool));
}

foreach (DataRow row in schema.Rows)
{
Expand Down Expand Up @@ -175,6 +185,11 @@ protected override DataTable ProcessResult(DataTable schema)
{
row["DOMAIN_NAME"] = null;
}

if (MajorVersionNumber >= 3)
{
row["IS_IDENTITY"] = (row["IDENTITY_TYPE"] != DBNull.Value);
}
}

schema.EndLoadData();
Expand All @@ -185,6 +200,10 @@ protected override DataTable ProcessResult(DataTable schema)
schema.Columns.Remove("COLUMN_ARRAY");
schema.Columns.Remove("FIELD_TYPE");
schema.Columns.Remove("CHARACTER_MAX_LENGTH");
if (MajorVersionNumber >= 3)
{
schema.Columns.Remove("IDENTITY_TYPE");
}

return schema;
}
Expand Down
31 changes: 23 additions & 8 deletions Provider/src/FirebirdSql.Data.FirebirdClient/Schema/FbSchema.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,14 @@

using FirebirdSql.Data.FirebirdClient;
using FirebirdSql.Data.Common;
using FirebirdSql.Data.Services;

namespace FirebirdSql.Data.Schema
{
#warning New datatypes

internal abstract class FbSchema
{
#region Constructors

public FbSchema()
{
}

#endregion

#region Abstract Methods

protected abstract StringBuilder GetCommandText(string[] restrictions);
Expand Down Expand Up @@ -74,6 +67,7 @@ public DataTable GetSchema(FbConnection connection, string collectionName, strin

protected FbCommand BuildCommand(FbConnection connection, string collectionName, string[] restrictions)
{
SetMajorVersionNumber(connection);
var filter = string.Format("CollectionName='{0}'", collectionName);
var builder = GetCommandText(restrictions);
var restriction = connection.GetSchema(DbMetaDataCollectionNames.Restrictions).Select(filter);
Expand Down Expand Up @@ -103,6 +97,7 @@ protected FbCommand BuildCommand(FbConnection connection, string collectionName,
return command;
}


protected virtual DataTable ProcessResult(DataTable schema)
{
return schema;
Expand All @@ -115,6 +110,19 @@ protected virtual string[] ParseRestrictions(string[] restrictions)

#endregion

#region Private Methods
/// <summary>
/// Determines the major version number from the Serverversion on the inner connection.
/// </summary>
/// <param name="connection">an open connection, which is used to determine the version number of the connected database server</param>
private void SetMajorVersionNumber(FbConnection connection)
{
var serverVersion = FbServerProperties.ParseServerVersion(connection.ServerVersion);
MajorVersionNumber = serverVersion.Major;
}
#endregion


#region Private Static Methods

private static void TrimStringFields(DataTable schema)
Expand All @@ -138,5 +146,12 @@ private static void TrimStringFields(DataTable schema)
}

#endregion

#region Properties
/// <summary>
/// The major version of the connected Firebird server
/// </summary>
protected int MajorVersionNumber { get; private set; }
#endregion
}
}