Closed simonw closed 2 months ago
Here's what that prototype does so far:
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.
This seems to work+AS+html_url_has_newline%2C%0D%0A++++MAX(CASE+WHEN+INSTR(id%2C+%27\n%27)+%3E+0+THEN+1+ELSE+0+END)+AS+id_has_newline%2C%0D%0A++++MAX(CASE+WHEN+INSTR(author%2C+%27\n%27)+%3E+0+THEN+1+ELSE+0+END)+AS+author_has_newline%2C%0D%0A++++MAX(CASE+WHEN+INSTR(node_id%2C+%27\n%27)+%3E+0+THEN+1+ELSE+0+END)+AS+node_id_has_newline%2C%0D%0A++++MAX(CASE+WHEN+INSTR(tag_name%2C+%27\n%27)+%3E+0+THEN+1+ELSE+0+END)+AS+tag_name_has_newline%2C%0D%0A++++MAX(CASE+WHEN+INSTR(target_commitish%2C+%27\n%27)+%3E+0+THEN+1+ELSE+0+END)+AS+target_commitish_has_newline%2C%0D%0A++++MAX(CASE+WHEN+INSTR(name%2C+%27\n%27)+%3E+0+THEN+1+ELSE+0+END)+AS+name_has_newline%2C%0D%0A++++MAX(CASE+WHEN+INSTR(draft%2C+%27\n%27)+%3E+0+THEN+1+ELSE+0+END)+AS+draft_has_newline%2C%0D%0A++++MAX(CASE+WHEN+INSTR(prerelease%2C+%27\n%27)+%3E+0+THEN+1+ELSE+0+END)+AS+prerelease_has_newline%2C%0D%0A++++MAX(CASE+WHEN+INSTR(created_at%2C+%27\n%27)+%3E+0+THEN+1+ELSE+0+END)+AS+created_at_has_newline%2C%0D%0A++++MAX(CASE+WHEN+INSTR(published_at%2C+%27\n%27)+%3E+0+THEN+1+ELSE+0+END)+AS+published_at_has_newline%2C%0D%0A++++MAX(CASE+WHEN+INSTR(body%2C+%27\n%27)+%3E+0+THEN+1+ELSE+0+END)+AS+body_has_newline%2C%0D%0A++++MAX(CASE+WHEN+INSTR(repo%2C+%27\n%27)+%3E+0+THEN+1+ELSE+0+END)+AS+repo_has_newline%2C%0D%0A++++MAX(CASE+WHEN+INSTR(reactions%2C+%27\n%27)+%3E+0+THEN+1+ELSE+0+END)+AS+reactions_has_newline%2C%0D%0A++++MAX(CASE+WHEN+INSTR(mentions_count%2C+%27\n%27)+%3E+0+THEN+1+ELSE+0+END)+AS+mentions_count_has_newline%0D%0AFROM+first_1000%3B%0D%0A):
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;
Takes the user to a pre-populated UPDATE query with all of the existing values filled in.