Skip to content

feat(sql): implement TypeID specification 0.3.0 in typeid-sql - #537

Merged
loreto merged 1 commit into
jetify-com:mainfrom
joschi:typeid-sql-spec-0.3
Aug 8, 2025
Merged

feat(sql): implement TypeID specification 0.3.0 in typeid-sql#537
loreto merged 1 commit into
jetify-com:mainfrom
joschi:typeid-sql-spec-0.3

Conversation

@joschi

@joschijoschi commented Jul 30, 2025

Copy link
Copy Markdown
Contributor

Summary

Implement TypeID specification 0.3.0 in typeid-sql.

Note

PLEASE tag the repository with the specification and provide a changelog. 🙏

How was it tested?

yarn install
yarn test

Community Contribution License

All community contributions in this pull request are licensed to the project maintainers under the terms of the Apache 2 License.

By creating this pull request I represent that I have the right to license the contributions to the project maintainers under the Apache 2 License as stated in the Community Contribution License.

@joschi

Copy link
Copy Markdown
ContributorAuthor

This would supersede #363 and #467.

@joschi
joschiforce-pushed the typeid-sql-spec-0.3 branch 2 times, most recently from be313e1 to 341d77bCompareJuly 30, 2025 14:42
@LucilleH
LucilleH requested review from Copilot and loretoJuly 30, 2025 18:25

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements TypeID specification 0.3.0 in the typeid-sql project, updating the prefix validation rules to allow underscores within prefixes while maintaining proper formatting constraints.

  • Updates prefix regex from [a-z]{0,63} to ^([a-z]([a-z_]{0,61}[a-z])?)?$ to allow underscores
  • Adds comprehensive test coverage for underscore handling in prefixes
  • Includes testing infrastructure and documentation improvements

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
FileDescription
typeid/typeid-sql/sql/03_typeid.sqlUpdates core TypeID functions with new prefix validation regex and improves parsing logic
typeid/typeid-sql/supabase/tests/03_typeid.test.sqlAdds tests for underscore handling and updates error message expectations
typeid/typeid-sql/supabase/tests/03_typed_text.test.sqlAdds underscore-specific test cases and updates validation error messages
typeid/typeid-sql/package.jsonAdds npm scripts for test automation
typeid/typeid-sql/README.mdDocuments testing procedures and requirements
Comments suppressed due to low confidence (2)

typeid/typeid-sql/supabase/tests/03_typeid.test.sql:128

  • The test description 'Print valid: valid-alphabet-underscores' is inconsistent with the test name 'valid-prefix-underscores'. Consider using 'Print valid: valid-prefix-underscores' for consistency.
 'Print valid: valid-alphabet-underscores'

typeid/typeid-sql/supabase/tests/03_typeid.test.sql:133

  • The test description 'Print valid: valid-alphabet-underscores' should be more specific since this test uses 'pre_____fix' with multiple consecutive underscores. Consider 'Print valid: valid-prefix-multiple-underscores'.
 'Print valid: valid-alphabet-underscores'

Comment threadtypeid/typeid-sql/sql/03_typeid.sql
end if;
prefix = split_part(typeid_str, '_', 1);
suffix = split_part(typeid_str, '_', 2);
matches = regexp_match(typeid_str, '^(.*)_(.*)$');

CopilotAIJul 30, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The regex ^(.*)_(.*)$ uses greedy matching which could be inefficient for strings with multiple underscores. Consider using ^(.*?)_(.*)$ with non-greedy matching or ^([^_]+)_(.*)$ to match only the first underscore more efficiently.

Suggested change
matches = regexp_match(typeid_str, '^(.*)_(.*)$');
matches = regexp_match(typeid_str, '^([^_]+)_(.*)$');

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@loreto WDYT? We could already match the correct regular expression here (prefix + suffix) but would lose fidelity in the error messages afterwards.

@joschi
joschiforce-pushed the typeid-sql-spec-0.3 branch from 341d77b to 18fca9cCompareAugust 6, 2025 14:42
@loreto

Copy link
Copy Markdown
Contributor

Apologies for the delay. I'll take a look at this PR today.

@loretoloreto left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@loreto
loreto merged commit 2a0e4ca into jetify-com:mainAug 8, 2025
9 checks passed
@joschi
joschi deleted the typeid-sql-spec-0.3 branch August 8, 2025 21:11
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@joschi@loreto