Skip to content

WIP: create sqlx.toml format #3383

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

Open
wants to merge 51 commits into
base: main
Choose a base branch
from
Open

WIP: create sqlx.toml format #3383

wants to merge 51 commits into from

Conversation

abonander
Copy link
Collaborator

@abonander abonander commented Jul 27, 2024

Reference sqlx.toml: https://github.com/launchbadge/sqlx/blob/sqlx-toml/sqlx-core/src/config/reference.toml

Once this is implemented, I'm planning on starting an alpha release cycle for 0.9.0 so that we can test this. It's not expected to be a breaking change but it's a large enough feature that it should probably go in a new major release, and there's a few other breaking API changes waiting in the wings.

The keys listed here are just the ones I've identified as needed for an MVP. Other keys may be added later backwards-compatibly.

Bikeshedding checklist:

  • snake_case or kebab-case for keys?
  • macros.column_overrides should maybe be called macros.table_overrides instead?
    • since the next level in the key is the table name, not the column name?

Implementation checklist

  • [common]
    • database-url-var
      • support in query macros
      • support in sqlx-cli
      • test
  • [macros]
    • preferred-crates
      • date-time
        • test
      • numeric
        • test
    • table-overrides
      • test
    • type-overrides
      • test
  • [migrate]
    • create-schemas
      • support in migrate!()
      • support in sqlx-cli
      • test (examples/postgres/multi-tenant)
    • table-name
      • support in migrate!()
      • support in sqlx-cli
      • test (examples/postgres/multi-tenant)
    • migrations-dir
      • support in migrate!()
      • support in #[sqlx::test]?
      • support in sqlx-cli
      • test (examples/postgres/multi-tenant)
    • ignored-chars
      • support in migrate!()
      • support in sqlx-cli
      • test
    • defaults
      • migration-type
        • test
      • migration-versioning
        • test

closes #121
closes #916
closes #3412

@abonander abonander force-pushed the sqlx-toml branch 2 times, most recently from 2b7fdba to 46dd260 Compare July 28, 2024 01:51
@abonander abonander force-pushed the sqlx-toml branch 7 times, most recently from fd557ad to 6c886f8 Compare August 2, 2024 03:41
@abonander abonander added this to the 0.9.0 milestone Sep 9, 2024
@abonander abonander force-pushed the sqlx-toml branch 3 times, most recently from af39902 to b67a83b Compare September 9, 2024 07:24
@abonander abonander force-pushed the sqlx-toml branch 2 times, most recently from 496f631 to 6cc3ac0 Compare September 18, 2024 08:58
@numfin
Copy link

numfin commented Apr 7, 2025

copying idea from another issue #3738 to here:

it would be nice to configure where DATABASE_URL and prepared queries is coming from. For example:

sqlx.conf (root)

root = true # or just find workspace root i guess
[macro.cache.foo]
database_url = { source = "dotenv", path = ".env", key = "DATABASE_URL" }
dir = "path_to_cache_folder"

sqlx.toml (projectA)

[macro]
database = { source = "dotenv", path = ".env", key = "DATABASE_URL" }

sqlx.toml (projectB)

[macro]
database = { source = "url", value = "postgres://..." }

sqlx.toml (projectC)

[macro]
database = { source = "cache", key = "foo" }

@abonander abonander marked this pull request as ready for review April 13, 2025 04:26
"optional sqlx feature `{feature_gate}` required for type {param_ty} of param #{param_num}",
)
} else {
format!("unsupported type {param_ty} for param #{param_num}")
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is the same confusing wording that already existed. I need to fix this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
4 participants