Skip to content

Commit ce9f5b5

Browse files
author
MPCoreDeveloper
committed
provider update
1 parent 58c600c commit ce9f5b5

File tree

1 file changed

+35
-35
lines changed

1 file changed

+35
-35
lines changed

SharpCoreDB.Data.Provider/SharpCoreDBConnection.cs

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ public override void Close()
152152
catch (Exception ex)
153153
{
154154
#if DEBUG
155-
System.Diagnostics.Debug.WriteLine($"[SharpCoreDB] Failed to save during close: {ex.Message}");
155+
System.Diagnostics.Debug.WriteLine($"{ex.Message}");
156156
#endif
157157
// Suppress exception to allow connection to close gracefully
158158
_ = ex; // Avoid unused variable warning
@@ -204,6 +204,40 @@ public override DataTable GetSchema()
204204
return GetSchema("MetaDataCollections");
205205
}
206206

207+
/// <summary>
208+
/// Gets schema information for a specific collection.
209+
/// </summary>
210+
public override DataTable GetSchema(string collectionName)
211+
{
212+
if (_state != ConnectionState.Open)
213+
throw new InvalidOperationException("Connection must be open to retrieve schema information.");
214+
215+
return collectionName.ToUpperInvariant() switch
216+
{
217+
"METADATACOLLECTIONS" => GetMetaDataCollectionsSchema(),
218+
"TABLES" => GetTablesSchema(),
219+
"COLUMNS" => GetColumnsSchema(),
220+
_ => throw new ArgumentException($"The requested collection '{collectionName}' is not defined.", nameof(collectionName))
221+
};
222+
}
223+
224+
/// <summary>
225+
/// Gets schema information for a specific collection with restrictions.
226+
/// </summary>
227+
public override DataTable GetSchema(string collectionName, string?[] restrictionValues)
228+
{
229+
if (_state != ConnectionState.Open)
230+
throw new InvalidOperationException("Connection must be open to retrieve schema information.");
231+
232+
var upper = collectionName.ToUpperInvariant();
233+
if (upper == "COLUMNS" && restrictionValues.Length > 0 && !string.IsNullOrWhiteSpace(restrictionValues[0]))
234+
{
235+
return GetColumnsSchema(restrictionValues[0]!);
236+
}
237+
238+
return GetSchema(collectionName);
239+
}
240+
207241
private static DataTable GetMetaDataCollectionsSchema()
208242
{
209243
var table = new DataTable("MetaDataCollections");
@@ -276,40 +310,6 @@ private DataTable GetColumnsSchema(string tableName)
276310
return table;
277311
}
278312

279-
/// <summary>
280-
/// Gets schema information for a specific collection.
281-
/// </summary>
282-
public override DataTable GetSchema(string collectionName)
283-
{
284-
if (_state != ConnectionState.Open)
285-
throw new InvalidOperationException("Connection must be open to retrieve schema information.");
286-
287-
return collectionName.ToUpperInvariant() switch
288-
{
289-
"METADATACOLLECTIONS" => GetMetaDataCollectionsSchema(),
290-
"TABLES" => GetTablesSchema(),
291-
"COLUMNS" => GetColumnsSchema(),
292-
_ => throw new ArgumentException($"The requested collection '{collectionName}' is not defined.", nameof(collectionName))
293-
};
294-
}
295-
296-
/// <summary>
297-
/// Gets schema information for a specific collection with restrictions.
298-
/// </summary>
299-
public override DataTable GetSchema(string collectionName, string?[] restrictionValues)
300-
{
301-
if (_state != ConnectionState.Open)
302-
throw new InvalidOperationException("Connection must be open to retrieve schema information.");
303-
304-
var upper = collectionName.ToUpperInvariant();
305-
if (upper == "COLUMNS" && restrictionValues.Length > 0 && !string.IsNullOrWhiteSpace(restrictionValues[0]))
306-
{
307-
return GetColumnsSchema(restrictionValues[0]!);
308-
}
309-
310-
return GetSchema(collectionName);
311-
}
312-
313313
private void ParseConnectionString(string connectionString)
314314
{
315315
if (string.IsNullOrWhiteSpace(connectionString))

0 commit comments

Comments
 (0)