Skip to content

Commit

Permalink
Resolves NDepend Avoid non-readonly static fields
Browse files Browse the repository at this point in the history
  • Loading branch information
David Shifflet committed Jul 22, 2019
1 parent bfc89fa commit 6451c8f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
2 changes: 1 addition & 1 deletion SqlWrangler/SqliteTools/SqliteTypes.cs
Expand Up @@ -3,7 +3,7 @@

namespace SqliteTools
{

[Obsolete]
public static class SqliteTypes
{
public static readonly Dictionary<Type, string> Types = new Dictionary<Type, string>()
Expand Down
19 changes: 18 additions & 1 deletion SqlWrangler/SqliteTools/Table.cs
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
Expand All @@ -18,6 +19,22 @@ public class Table
/// </summary>
private string Name { get; set; }

public static readonly Dictionary<Type, string> SqlLiteTypes = new Dictionary<Type, string>()
{
{typeof(short), "SMALLINT"},
{typeof(int), "INT"},
{typeof(long), "BIGINT"},
{typeof(byte[]), "BLOB"},
{typeof(bool), "BOOLEAN"},
{typeof(string), "VARCHAR"},
{typeof(char[]), "VARCHAR"},
{typeof(DateTime), "DATETIME"},
{typeof(decimal), "DECIMAL(10,5)"}, //todo need to think about this one...
{typeof(double), "FLOAT"},
{typeof(float), "REAL"},
{typeof(byte), "TINYINT"}
};

public string ActualName
{
get
Expand Down Expand Up @@ -76,7 +93,7 @@ private string GenerateCreateTableSql(DataTable table)

//if these types need to be more precise like for decimal...
//we would need to change it so it works off a datatble returned from something like DataReader.GetSchemaTable.
var sqlType = SqliteTypes.Types[col.DataType];
var sqlType = SqlLiteTypes[col.DataType];

if (col.MaxLength > 0) sqlType += $"({col.MaxLength})";

Expand Down

0 comments on commit 6451c8f

Please sign in to comment.