-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
explore: can the row page support views? #49
Comments
A horrendous idea: we could add a
How ought the schema signal that it wants those fields to be populated? A proposal: CREATE VIEW needs_review AS
/* set approved_by=current_actor() */
/* set approved_at=datetime() */
SELECT
id,
'Look closely at the value. Do you approve it?' AS instructions,
value AS value_aliased_so_as_not_to_be_editable,
approved
FROM data
WHERE approved IS NULL I think that's actually... not terrible? You could let them express other transformations in there, for example they could have access to |
Validating that triggers work the way I expect: CREATE TABLE data(id integer primary key, name text, age integer);
INSERT INTO data(name,age) VALUES ('colin', 37);
INSERT INTO data(name,age) VALUES ('jenn', 38);
CREATE VIEW view AS SELECT * FROM data;
CREATE TRIGGER update_underlying_fields INSTEAD OF UPDATE OF age, name ON view
BEGIN
UPDATE data SET age = new.age, name = new.name WHERE id = old.id;
END;
UPDATE view SET age = 1, name = 'charlie' WHERE id = 1;
UPDATE view SET age = 10 WHERE id = 2;
SELECT * FROM view; Yeah, that gives the expected result:
|
I'm actually getting pretty jazzed about views being the initial foothold for editing data. They solve two common issues:
|
As part of #48, it might be valuable to let users define a subset of a table as a view. For example, if you have:
You might want to create a queue of records-to-be-reviewed, like:
That view declares that you should be able to edit the
approved
field.id
isn't editable, as it's part of the pkey. The other two columns are aliased, and so aren't editable.Then, you'd use SQLite's
INSTEAD OF
trigger to permit updates against the view. You'd probably want some jazz to create these triggers automatically, so users can get by with basic SQL understanding.Questions:
approved_at
andapproved_by
in a somewhat natural wayRow not found: ['1']
. It looks like these two things need to be fixed:'View' object has no attribute 'update'
. Compare View vs Table#updateThe text was updated successfully, but these errors were encountered: