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
Original file line number Diff line number Diff line change
Expand Up @@ -155,14 +155,15 @@ private IEnumerable<DatabaseTable> GetTables(DbConnection connection, IEnumerabl
command.CommandText = new StringBuilder()
.AppendLine("SELECT \"name\"")
.AppendLine("FROM \"sqlite_master\"")
.Append("WHERE \"type\" = 'table' AND instr(\"name\", 'sqlite_') <> 1 AND \"name\" NOT IN ('")
.Append("WHERE \"type\" IN ('table', 'view') AND instr(\"name\", 'sqlite_') <> 1 AND \"name\" NOT IN ('")
.Append(HistoryRepository.DefaultTableName)
.Append("', 'ElementaryGeometries', 'geometry_columns', 'geometry_columns_auth', ")
.Append("'geometry_columns_field_infos', 'geometry_columns_statistics', 'geometry_columns_time', ")
.Append("'spatial_ref_sys', 'spatial_ref_sys_aux', 'SpatialIndex', 'spatialite_history', ")
.Append("'sql_statements_log', 'views_geometry_columns', 'views_geometry_columns_auth', ")
.Append("'views_geometry_columns_field_infos', 'views_geometry_columns_statistics', ")
.Append("'virts_geometry_columns', 'virts_geometry_columns_auth', ")
.Append("'geom_cols_ref_sys', 'spatial_ref_sys_all', ")
.AppendLine("'virts_geometry_columns_field_infos', 'virts_geometry_columns_statistics');")
.ToString();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,33 @@ Name text NOT NULL
"DROP TABLE MountainsColumns;");
}

[Fact]
public void Create_view_columns()
{
Test(
@"
CREATE VIEW MountainsColumnsView
AS
SELECT
CAST(100 AS integer) AS Id,
CAST('' AS text) AS Name;",
Enumerable.Empty<string>(),
Enumerable.Empty<string>(),
dbModel =>
{
var table = dbModel.Tables.Single();

Assert.Equal(2, table.Columns.Count);
Assert.Equal(null, table.PrimaryKey);
Assert.All(
table.Columns, c => Assert.Equal("MountainsColumnsView", c.Table.Name));

Assert.Single(table.Columns.Where(c => c.Name == "Id"));
Assert.Single(table.Columns.Where(c => c.Name == "Name"));
},
"DROP VIEW MountainsColumnsView;");
}

[Fact]
public void Create_primary_key()
{
Expand Down