Skip to content

Allow Bulk Insert for a specified list of columns (#311) - #359

Closed
NTmatter wants to merge 1 commit into
tiberius-rs:mainfrom
NTmatter:bulk-columns
Closed

NTmatter wants to merge 1 commit into
tiberius-rs:mainfrom
NTmatter:bulk-columns

Conversation

@NTmatter

@NTmatter NTmatter commented Oct 1, 2024

Copy link
Copy Markdown
Contributor

Adds bulk_insert_columns(self, table, columns) and turns bulk_insert(self, table) into a compatibility shim that calls self.bulk_insert_columns(table, &["*"]), maintaining the existing behaviour.

This should simplify bulk inserts in cases where column order may be unpredictable, or only a subset of columns need to be inserted.

Adds `bulk_insert_columns(self, table, columns)` and turns `bulk_insert(self, table)` into
a compatibility shim that calls `self.bulk_insert_columns(table, &["*"])`, maintaining the
existing behaviour.
MattJackson referenced this pull request in MattJackson/tiberius-ng Aug 29, 2026
joelparkerhenderson added a commit to mssql-rust/mssql-rust that referenced this pull request Aug 29, 2026
Mirrors tiberius-rs/tiberius#359, fixes upstream issue #311.
Client::bulk_insert_columns(table, columns) lets callers restrict and
order the columns used in a BULK INSERT, so source data that doesn't
cover every column or is in a different column order than the table
can still use bulk_insert. bulk_insert(table) becomes a thin wrapper
calling bulk_insert_columns(table, &["*"]).

Ported the test macro to this fork's mssql/pastey naming.

Verified live against a real SQL Server (Azure SQL Edge via rustls):
all 8 new tests pass (default/override column subsets, both orderings,
optional and NOT NULL variants), plus the full 88-test tests/bulk.rs
suite. Also verified: cargo check across all 6 CI feature
combinations, cargo clippy --all-targets, cargo fmt --check, and cargo
test --lib (153 passing).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0156Di1tRRLsJK8ctU1AmAJr
MattJackson referenced this pull request in MattJackson/tiberius-ng Aug 29, 2026
…397, #217, #403)

Adapted from upstream #398 (author @etylermoss), reconciled with the
already-integrated bulk_insert_columns (#359):
- Client::column_metadata(table, columns) returns owned Vec<MetaDataColumn>
  (names, types, size/precision/scale, nullability, identity); bulk insert
  now shares this path.
- MetaDataColumn::col_name()/base() accessors; BaseMetaDataColumn::
  is_identity()/is_nullable()/ty()/flags() (resolves #403).
joelparkerhenderson added a commit to mssql-rust/mssql-rust that referenced this pull request Aug 30, 2026
Mirrors tiberius-rs/tiberius#359, fixes upstream issue #311.
Client::bulk_insert_columns(table, columns) lets callers restrict and
order the columns used in a BULK INSERT, so source data that doesn't
cover every column or is in a different column order than the table
can still use bulk_insert. bulk_insert(table) becomes a thin wrapper
calling bulk_insert_columns(table, &["*"]).

Ported the test macro to this fork's mssql/pastey naming.

Verified live against a real SQL Server (Azure SQL Edge via rustls):
all 8 new tests pass (default/override column subsets, both orderings,
optional and NOT NULL variants), plus the full 88-test tests/bulk.rs
suite. Also verified: cargo check across all 6 CI feature
combinations, cargo clippy --all-targets, cargo fmt --check, and cargo
test --lib (153 passing).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0156Di1tRRLsJK8ctU1AmAJr
MattJackson added a commit that referenced this pull request Sep 3, 2026
(cherry picked from commit b114498)
MattJackson added a commit that referenced this pull request Sep 3, 2026
, #217, #403)

Adapted from upstream #398 (author @etylermoss), reconciled with the
already-integrated bulk_insert_columns (#359):
- Client::column_metadata(table, columns) returns owned Vec<MetaDataColumn>
  (names, types, size/precision/scale, nullability, identity); bulk insert
  now shares this path.
- MetaDataColumn::col_name()/base() accessors; BaseMetaDataColumn::
  is_identity()/is_nullable()/ty()/flags() (resolves #403).
MattJackson added a commit that referenced this pull request Sep 4, 2026
(cherry picked from commit b114498)
MattJackson added a commit that referenced this pull request Sep 4, 2026
, #217, #403)

Adapted from upstream #398 (author @etylermoss), reconciled with the
already-integrated bulk_insert_columns (#359):
- Client::column_metadata(table, columns) returns owned Vec<MetaDataColumn>
  (names, types, size/precision/scale, nullability, identity); bulk insert
  now shares this path.
- MetaDataColumn::col_name()/base() accessors; BaseMetaDataColumn::
  is_identity()/is_nullable()/ty()/flags() (resolves #403).
MattJackson added a commit that referenced this pull request Sep 6, 2026
(cherry picked from commit b114498)
MattJackson added a commit that referenced this pull request Sep 6, 2026
, #217, #403)

Adapted from upstream #398 (author @etylermoss), reconciled with the
already-integrated bulk_insert_columns (#359):
- Client::column_metadata(table, columns) returns owned Vec<MetaDataColumn>
  (names, types, size/precision/scale, nullability, identity); bulk insert
  now shares this path.
- MetaDataColumn::col_name()/base() accessors; BaseMetaDataColumn::
  is_identity()/is_nullable()/ty()/flags() (resolves #403).
MattJackson added a commit that referenced this pull request Sep 15, 2026
(cherry picked from commit b114498)
MattJackson added a commit that referenced this pull request Sep 16, 2026
(cherry picked from commit b114498)
MattJackson added a commit that referenced this pull request Sep 16, 2026
, #217, #403)

Adapted from upstream #398 (author @etylermoss), reconciled with the
already-integrated bulk_insert_columns (#359):
- Client::column_metadata(table, columns) returns owned Vec<MetaDataColumn>
  (names, types, size/precision/scale, nullability, identity); bulk insert
  now shares this path.
- MetaDataColumn::col_name()/base() accessors; BaseMetaDataColumn::
  is_identity()/is_nullable()/ty()/flags() (resolves #403).
MattJackson added a commit that referenced this pull request Sep 24, 2026
, #217, #403)

Adapted from upstream #398 (author @etylermoss), reconciled with the
already-integrated bulk_insert_columns (#359):
- Client::column_metadata(table, columns) returns owned Vec<MetaDataColumn>
  (names, types, size/precision/scale, nullability, identity); bulk insert
  now shares this path.
- MetaDataColumn::col_name()/base() accessors; BaseMetaDataColumn::
  is_identity()/is_nullable()/ty()/flags() (resolves #403).
@MattJackson

Copy link
Copy Markdown
Contributor

Included in #441 — shipped in tiberius v0.13.0. Thanks for this! Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants