Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ directly without re-collecting.
| `tsrange` | `sqlx::postgres::types::PgRange<chrono::NaiveDateTime>` |
| `tstzrange` | `sqlx::postgres::types::PgRange<chrono::DateTime<chrono::Utc>>` |
| `daterange` | `sqlx::postgres::types::PgRange<chrono::NaiveDate>` |
| `bit` / `varbit` | `bit_vec::BitVec` |
| `bit` / `varbit` | `sqlx::types::BitVec` |
| PostgreSQL ENUM | generated Rust enum |
| PostgreSQL composite | generated Rust struct |

Expand Down
1 change: 0 additions & 1 deletion examples/advanced-types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ publish = false

[dependencies]
bigdecimal = "0.4"
bit-vec = "0.8"
chrono = "0.4"
sqlx = { workspace = true }
tokio = { workspace = true }
2 changes: 1 addition & 1 deletion examples/advanced-types/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ async fn test_advanced_types_roundtrip() {
.await
.unwrap();

let flags = bit_vec::BitVec::from_bytes(&[0b10101010]);
let flags = sqlx::types::BitVec::from_bytes(&[0b10101010]);
let now = chrono::Utc::now();
let later = now + chrono::Duration::hours(1);
let window = sqlx::postgres::types::PgRange::from((
Expand Down
4 changes: 2 additions & 2 deletions examples/advanced-types/src/queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const GET_EVENT: &str = "SELECT id, name, flags, event_window FROM events WHERE
pub struct GetEventRow {
pub id: i64,
pub name: String,
pub flags: bit_vec::BitVec,
pub flags: sqlx::types::BitVec,
pub event_window: sqlx::postgres::types::PgRange<chrono::DateTime<chrono::Utc>>,
}
pub async fn get_event<E: AsExecutor>(mut db: E, id: i64) -> Result<GetEventRow, sqlx::Error> {
Expand All @@ -58,7 +58,7 @@ const LIST_EVENTS: &str = "SELECT id, name, flags, event_window FROM events";
pub struct ListEventsRow {
pub id: i64,
pub name: String,
pub flags: bit_vec::BitVec,
pub flags: sqlx::types::BitVec,
pub event_window: sqlx::postgres::types::PgRange<chrono::DateTime<chrono::Utc>>,
}
pub async fn list_events<E: AsExecutor>(mut db: E) -> Result<Vec<ListEventsRow>, sqlx::Error> {
Expand Down
2 changes: 1 addition & 1 deletion src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ impl TypeMap {

// Bit types
for n in ["bit", "varbit", "pg_catalog.varbit"] {
defaults.insert(n, ("bit_vec::BitVec", false));
defaults.insert(n, ("sqlx::types::BitVec", false));
}

let mut type_overrides: HashMap<String, OverrideEntry> = HashMap::new();
Expand Down
5 changes: 4 additions & 1 deletion tests/codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,10 @@ fn snapshot_range_types() {
let code = String::from_utf8(resp.files[0].contents.clone()).unwrap();
assert_codegen_snapshot("range_types", &code);
assert!(code.contains("PgRange"), "expected PgRange in:\n{code}");
assert!(code.contains("BitVec"), "expected BitVec in:\n{code}");
assert!(
code.contains("sqlx::types::BitVec"),
"expected SQLx BitVec in:\n{code}"
);
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion tests/snapshots/codegen__range_types.snap
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ pub const GET_EVENT_WINDOW: &str = "SELECT id, window, flags FROM events WHERE i
pub struct GetEventWindowRow {
pub id: i64,
pub window: sqlx::postgres::types::PgRange<chrono::DateTime<chrono::Utc>>,
pub flags: bit_vec::BitVec,
pub flags: sqlx::types::BitVec,
}
pub async fn get_event_window<E: AsExecutor>(
mut db: E,
Expand Down