Skip to content

PowerShell 7: CREATE table works, SELECT table doesnt #28

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
slashd opened this issue Apr 3, 2020 · 4 comments
Open

PowerShell 7: CREATE table works, SELECT table doesnt #28

slashd opened this issue Apr 3, 2020 · 4 comments

Comments

@slashd
Copy link

slashd commented Apr 3, 2020

Works fine in Windows PowerShell 5, doesnt work in 7

Works: CREATE table Customers
Doesnt work: SELECT * from Customers

InvalidOperation: \PowerShell\Modules\PSSQLite\1.0.3\Invoke-SqliteQuery.ps1:518:25
Line |
518 | [DBNullScrubber]::DataRowToPSObject($row)
| ~~~~~~~~~~~~~~~~
| Unable to find type [DBNullScrubber].

@RamblingCookieMonster
Copy link
Owner

Hi!

Yes, the default of As PSObject will not work outside of Windows PowerShell.

Don't have time to fix this (e.g. change default for *nix), but as a workaround, switch -As to something else:

[ValidateSet("DataSet", "DataTable", "DataRow","PSObject","SingleValue")]
[string]
$As="PSObject"

Presumably -as DataRow

Thanks!

@bgwdotdev
Copy link
Contributor

bgwdotdev commented Jun 1, 2020

Hm, I'm sure I fixed this originally when adding core support... Though I changed a lot since then. I will try take another look at this some time this week if I can.

@slashd can you confirm what OS you are running pwsh 7 on? If it is windows, I have a feeling I know what the problem is...

Thanks

@bgwdotdev
Copy link
Contributor

@slashd I have tried this on both linux and windows with PowerShell 7 and have been unable to replicate this issue.

I believe I fixed this in core by reimplementing the [DBNullScrubber] under this commit:
095b701

I do not have a mac available to test in case the issue was on that platform.

If you are still having this issue, please provide details on your PS version, OS and PSSqlite module version.

@RamblingCookieMonster May want to consider closing this if there is no follow up?

My test:

PSSQLite> $d = { datasource = "./test.db" }
PSSQLite> Invoke-SqliteQuery @d -Query "create table customer (name)"
PSSQLite> Invoke-SqliteQuery @d -Query "insert into customer (name) values ('bob')"
PSSQLite> Invoke-SqliteQuery @d -Query "select * from customer"

name
----
bob

@Szeraax
Copy link

Szeraax commented Apr 4, 2023

Works for Invoke-SqlCmd2 as well. Thank you, fffnite for taking the time to troubleshoot this for the community.

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

No branches or pull requests

4 participants