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

Write-DbaDbTableData - Added ColumnMap like in Import-DbaCsv #7370

Merged
merged 5 commits into from
May 26, 2021

Conversation

andreasjordan
Copy link
Contributor

Type of Change

  • Bug fix (non-breaking change, fixes # )
  • New feature (non-breaking change, adds functionality, fixes Write-DbaDbTableData: add ColumnMap parameter #6683 )
  • Breaking change (effects multiple commands or functionality, fixes # )
  • Ran manual Pester test and has passed (`.\tests\manual.pester.ps1)
  • Adding code coverage to existing functionality
  • Pester test is included
  • If new file reference added for test, has is been added to github.com/sqlcollaborative/appveyor-lab ?
  • Nunit test is included
  • Documentation
  • Build system

Purpose

Have the same mapping feature like in Import-DbaCsv

Approach

Just copied the code, that was easy.

Commands to test

$server = Connect-DbaInstance -SqlInstance SRV1
$server.Invoke("CREATE TABLE tempdb.dbo.test (col1 INT, col2 VARCHAR(100))")
$data = Invoke-DbaQuery -SqlInstance $server -Query "SELECT 123 AS value1, 'Hello world' AS value2" -As DataSet
$data | Write-DbaDbTableData -SqlInstance $server -Table 'tempdb.dbo.test' -ColumnMap @{ value1 = 'col1' ; value2 = 'col2' }

Screenshots

image

@andreasjordan
Copy link
Contributor Author

I think the datatype is wrong: [hashtable[]]$ColumnMap should be [hashtable]$ColumnMap, because only one hashtable is allowed. Shall I add this fix in both Write-DbaDbTableData and Import-DbaCsv with this pull request or open a new issue?

@potatoqualitee
Copy link
Member

Yeah, that makes sense @andreasjordan. You can fix in the other commands and add it to this PR.

@potatoqualitee
Copy link
Member

Looks fab 🤩 Thank you!

@potatoqualitee potatoqualitee merged commit fb61b3a into development May 26, 2021
@potatoqualitee potatoqualitee deleted the 6683_WriteDbaDbTableData_ColumnMap branch May 26, 2021 14:45
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.

Write-DbaDbTableData: add ColumnMap parameter
2 participants