PSSQLite icon indicating copy to clipboard operation
PSSQLite copied to clipboard

PowerShell 7: CREATE table works, SELECT table doesnt

Open slashd opened this issue 5 years ago • 4 comments

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].

slashd avatar Apr 03 '20 11:04 slashd

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!

RamblingCookieMonster avatar May 20 '20 17:05 RamblingCookieMonster

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 avatar Jun 01 '20 14:06 bgwdotdev

@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: https://github.com/RamblingCookieMonster/PSSQLite/commit/095b70138134bc20f633163272865962cd6c6bd6

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

bgwdotdev avatar Jul 24 '20 06:07 bgwdotdev

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

Szeraax avatar Apr 04 '23 03:04 Szeraax