Skip to content

Commit 96e451c

Browse files
authored
Merge pull request #132 from Mytherin/issue121
Fix #121: pass schema into CreateViewInfo::FromCreateView
2 parents 5f4ecea + bc4c7ae commit 96e451c

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

src/storage/sqlite_transaction.cpp

+2-3
Original file line numberDiff line numberDiff line change
@@ -135,16 +135,15 @@ optional_ptr<CatalogEntry> SQLiteTransaction::GetCatalogEntry(const string &entr
135135
string sql;
136136
db->GetViewInfo(entry_name, sql);
137137

138-
139138
unique_ptr<CreateViewInfo> view_info;
140139
try {
141-
view_info = CreateViewInfo::FromCreateView(*context.lock(), sql);
140+
view_info = CreateViewInfo::FromCreateView(*context.lock(), sqlite_catalog.GetMainSchema(), sql);
142141
} catch(std::exception &ex) {
143142
auto view_sql = ExtractSelectStatement(sql);
144143
auto catalog_name = StringUtil::Replace(sqlite_catalog.GetName(), "\"", "\"\"");
145144
auto escaped_view_sql = StringUtil::Replace(view_sql, "'", "''");
146145
auto view_def = StringUtil::Format("CREATE VIEW %s AS FROM sqlite_query(\"%s\", '%s')", entry_name, catalog_name, escaped_view_sql);
147-
view_info = CreateViewInfo::FromCreateView(*context.lock(), view_def);
146+
view_info = CreateViewInfo::FromCreateView(*context.lock(), sqlite_catalog.GetMainSchema(), view_def);
148147
}
149148
view_info->internal = false;
150149
result = make_uniq<ViewCatalogEntry>(sqlite_catalog, sqlite_catalog.GetMainSchema(), *view_info);

test/sql/storage/attach_describe.test

+6
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ DESCRIBE s1.test
1616
i BIGINT YES PRI NULL NULL
1717
j BIGINT YES NULL 42 NULL
1818

19+
query IIIIII
20+
DESCRIBE TABLE s1.test
21+
----
22+
i BIGINT YES PRI NULL NULL
23+
j BIGINT YES NULL 42 NULL
24+
1925
query ITTTTT
2026
PRAGMA table_info('s1.test');
2127
----
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# name: test/sql/storage/attach_show_tables.test
2+
# description:
3+
# group: [sqlite_storage]
4+
5+
require sqlite_scanner
6+
7+
statement ok
8+
ATTACH 'data/db/sakila.db' AS sakila (TYPE SQLITE, READ_ONLY)
9+
10+
statement ok
11+
SHOW TABLES

0 commit comments

Comments
 (0)