Skip to content
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

Closed
simonw opened this issue Mar 18, 2024 · 4 comments
Closed

Row action item for "Update using SQL" #10

simonw opened this issue Mar 18, 2024 · 4 comments
Labels
enhancement New feature or request

Comments

@simonw
Copy link
Owner

simonw commented Mar 18, 2024

Takes the user to a pre-populated UPDATE query with all of the existing values filled in.

@simonw simonw added the enhancement New feature or request label Mar 18, 2024
@simonw
Copy link
Owner Author

simonw commented Mar 18, 2024

Here's what that prototype does so far:

row-action-prototype

@simonw
Copy link
Owner Author

simonw commented Mar 18, 2024

A table action for composing insert queries would be useful here too.

@simonw
Copy link
Owner Author

simonw commented Mar 18, 2024

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.

@simonw
Copy link
Owner Author

simonw commented Mar 18, 2024

This seems to work:

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 4, 2024
simonw added a commit that referenced this issue Sep 4, 2024
@simonw simonw closed this as completed in 4bfd318 Sep 4, 2024
simonw added a commit that referenced this issue Sep 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant