Views now show their SQL, are handled a bit better

Refs #66
This commit is contained in:
Simon Willison 2017-11-12 12:31:46 -08:00
commit ff2ab9dc7d
4 changed files with 43 additions and 27 deletions

View file

@ -91,6 +91,21 @@ def test_table_page(three_table_app_client):
}]
def test_view(three_table_app_client):
_, response = three_table_app_client.get('/four_tables/simple_view')
assert response.status == 200
_, response = three_table_app_client.get('/four_tables/simple_view.jsono')
assert response.status == 200
data = response.json
assert data['rows'] == [{
'upper_content': 'HELLO',
'content': 'hello',
}, {
'upper_content': 'WORLD',
'content': 'world',
}]
FOUR_TABLES = '''
CREATE TABLE simple_primary_key (
pk varchar(30) primary key,
@ -115,4 +130,7 @@ CREATE TABLE "Table With Space In Name" (
INSERT INTO simple_primary_key VALUES (1, 'hello');
INSERT INTO simple_primary_key VALUES (2, 'world');
CREATE VIEW simple_view AS
SELECT content, upper(content) AS upper_content FROM simple_primary_key;
'''