Skip to content
Permalink
Browse files

Resolves NDepend Avoid non-readonly static fields

  • Loading branch information...
David Shifflet
David Shifflet committed Jul 22, 2019
1 parent bfc89fa commit 6451c8f1a79ac486d7827f10b2ae477a0c84a081
Showing with 19 additions and 2 deletions.
  1. +1 −1 SqlWrangler/SqliteTools/SqliteTypes.cs
  2. +18 −1 SqlWrangler/SqliteTools/Table.cs
@@ -3,7 +3,7 @@

namespace SqliteTools
{

[Obsolete]
public static class SqliteTypes
{
public static readonly Dictionary<Type, string> Types = new Dictionary<Type, string>()
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
@@ -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
@@ -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})";

0 comments on commit 6451c8f

Please sign in to comment.
You can’t perform that action at this time.