v2kiran / PSLiteDB

PowerShell wrapper for LiteDB

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

"Schema" not getting updated

povlhp opened this issue · comments

Having some issues with the "schema" not being updated.
I have inserted some documents, then I enrich them (find them, update a local copy - sometimes with extra fields, delete the old document, insert the updated document with new field).
The problem is, the GUI tools and select $ all returns only the initial fields of the documents inserted.
We need a way to either update the "Schema" - Or inserts should check if new fields are present.

If I do a select where NewField > '', then my results includes the NewField, since it is present in first (?) or all records. If I do a select $ on all records, I do NOT get the new fields in the response.

Of course selecting individual documents by uniq search criteria will return all fields, since the one document have them.

I suspect you are running into a powershell formatting feature rather than an issue with the db.
An cases like these an example or screenshots would help.

Anyway is this what are seeing?

$array = @( [pscustomobject]@{prop1=1;prop2=2},[pscustomobject]@{prop1=1;prop2=2;prop3=3},[pscustomobject]@{prop1=1;prop2=2;prop3=3})

❯ $array

prop1 prop2
----- -----
    1     2
    1     2
    1     2

if yes then thats how powershell is designed so try outputting the objects as BSON instead of psobject which is the default.
or convert to json

find-litedbdocument mycol -As bson

Reported is as an error in LiteDB. The GUI tools do it as well.
Guess what we really need is LiteDB function to ALTER TABLE to enforce display of some columns. Or another way to refresh schema.