Better issue report for the Sqlite version of Massive #86

Closed
arhoads76 opened this Issue Sep 19, 2011 · 1 comment

Projects

None yet

2 participants

@arhoads76

In the Sqlite version of Massive, the Schema property returns a CREATE TABLE string. It is certainly possible to parse it to get similar data as is returned from the Sql Server version of Massive. However, the following code will return column names and types like the Sql Server version of Massive:

IEnumerable<dynamic> _schema;
public IEnumerable<dynamic> Schema
{
    get
    {
        if (_schema == null) {
            var rows = new List<dynamic>();
            foreach (var row in Query("PRAGMA table_info('" + TableName + "')")) {
                rows.Add(new {
                    COLUMN_NAME = (row as IDictionary<string,object>)["name"].ToString(),
                    DATA_TYPE   = (row as IDictionary<string,object>)["type"].ToString(),
                    IS_NULLABLE = (row as IDictionary<string,object>)["notnull"].ToString() == "0" ? "NO" : "YES",
                });
            }
            _schema = rows;
        }
        return _schema;
    }
}
@robconery
Collaborator

Pull requests work a treat.

@robconery robconery closed this Sep 28, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment