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

If Column value in first record is null, column type is erroneously set to string #26

Open
Chirishman opened this issue Jan 23, 2018 · 3 comments

Comments

@Chirishman
Copy link

I'm working with Out-DataTable and AD and when I attempt to pass AD User objects through Out-DataTable it sets the column type of AccountExpirationDate to String because the value is null on the first record.

@RamblingCookieMonster
Copy link
Owner

Haha, good catch, looks like I added a note when tweaking the original from Chad!

How would you expect this to work? I suppose we could use something that looks at all property types for all objects, and if it sees things like null and string, it picks string (same for other types)?

I'd be up for a PR - if it could be done without too much of a mess, could have it behave as is by default, add a ScanAllPropertyValues or some similar switch that implements the more thorough, but slower code

Cheers!

@Chirishman
Copy link
Author

Chirishman commented Jan 29, 2018

Yeah, I've been thinking about the best way to solve it because it messes things up when I use it in conjunction with Invoke-SQLiteBulkCopy. For some reason I don't get an error on insert but I do on select when my select includes a column where a bad/conflicting typing has been created due to this bug.

Edit:
The other benefit of doing a more complete check of datatypes/checking more or all rows is to have an early flag on any objects which have inconsistent datatypes on the same property.

@LUCScape
Copy link

Could offer an optional paramenter to input a list of data types of the columns?

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

3 participants