-
-
Notifications
You must be signed in to change notification settings - Fork 2
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
Row action item for "Update using SQL" #10
Labels
enhancement
New feature or request
Comments
simonw
added a commit
that referenced
this issue
Mar 18, 2024
A table action for composing insert queries would be useful here too. |
The code that detects if a field should be a textarea currently only looks for newlines in the values in the current row - a smarter approach (and one that would also work for insert statements at the table level) would be to scan the first ~1,000 rows looking for newline characters in each column. |
WITH first_1000 AS (
SELECT
html_url,
id,
author,
node_id,
tag_name,
target_commitish,
name,
draft,
prerelease,
created_at,
published_at,
body,
repo,
reactions,
mentions_count
FROM releases
LIMIT 1000
)
SELECT
MAX(CASE WHEN INSTR(html_url, '\n') > 0 THEN 1 ELSE 0 END) AS html_url_has_newline,
MAX(CASE WHEN INSTR(id, '\n') > 0 THEN 1 ELSE 0 END) AS id_has_newline,
MAX(CASE WHEN INSTR(author, '\n') > 0 THEN 1 ELSE 0 END) AS author_has_newline,
MAX(CASE WHEN INSTR(node_id, '\n') > 0 THEN 1 ELSE 0 END) AS node_id_has_newline,
MAX(CASE WHEN INSTR(tag_name, '\n') > 0 THEN 1 ELSE 0 END) AS tag_name_has_newline,
MAX(CASE WHEN INSTR(target_commitish, '\n') > 0 THEN 1 ELSE 0 END) AS target_commitish_has_newline,
MAX(CASE WHEN INSTR(name, '\n') > 0 THEN 1 ELSE 0 END) AS name_has_newline,
MAX(CASE WHEN INSTR(draft, '\n') > 0 THEN 1 ELSE 0 END) AS draft_has_newline,
MAX(CASE WHEN INSTR(prerelease, '\n') > 0 THEN 1 ELSE 0 END) AS prerelease_has_newline,
MAX(CASE WHEN INSTR(created_at, '\n') > 0 THEN 1 ELSE 0 END) AS created_at_has_newline,
MAX(CASE WHEN INSTR(published_at, '\n') > 0 THEN 1 ELSE 0 END) AS published_at_has_newline,
MAX(CASE WHEN INSTR(body, '\n') > 0 THEN 1 ELSE 0 END) AS body_has_newline,
MAX(CASE WHEN INSTR(repo, '\n') > 0 THEN 1 ELSE 0 END) AS repo_has_newline,
MAX(CASE WHEN INSTR(reactions, '\n') > 0 THEN 1 ELSE 0 END) AS reactions_has_newline,
MAX(CASE WHEN INSTR(mentions_count, '\n') > 0 THEN 1 ELSE 0 END) AS mentions_count_has_newline
FROM first_1000; |
simonw
added a commit
that referenced
this issue
Sep 3, 2024
simonw
added a commit
that referenced
this issue
Sep 4, 2024
simonw
added a commit
that referenced
this issue
Sep 4, 2024
simonw
added a commit
that referenced
this issue
Sep 4, 2024
simonw
added a commit
that referenced
this issue
Sep 4, 2024
Refs #12, #10 Refs simonw/datasette#2417
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Takes the user to a pre-populated UPDATE query with all of the existing values filled in.
The text was updated successfully, but these errors were encountered: