SCRT-HQ / PSGSuite

Powershell module for Google / G Suite API calls wrapped in handy functions. Authentication is established using a service account via P12 key to negate the consent popup and allow for greater handsoff automation capabilities
https://psgsuite.io/
Apache License 2.0
235 stars 67 forks source link

Get-GSDriveFile -Fields parameter is never honored #190

Closed WJurecki closed 5 years ago

WJurecki commented 5 years ago

Describe the bug When Get-GSDriveFile is executed with the -Fields parameter is not honored and all fields are returned.

This is caused because -Fields is only evaluated if -Projection is not specified, however -Projection has a default defined as 'Full' and there is no way to prevent this. Therefore, -Fields are never evaluated and utilized.

To Reproduce Steps to reproduce the behavior:

  1. Get-GSDriveFile -FileId '1234'
  2. Get-GSDriveFile -FileId '1234' -Fields 'id'

Both have same result with all fields returned and populated.

Expected behavior when Get-GSDriveFile -FileId '1234' -Fields 'id' is used the returned object should only have the id property filled.

Comments Simply removing the default on -Projection fixes this immediate problem, but, significantly changes default behavior. Reversing the logic so as to check -Fields first could allow a less impactful 'fix'. I'm not certain what to suggest as the best solution.

Environment (please complete the following information):

scrthq commented 5 years ago

@WJurecki - Thanks for opening this up! I'm on it, I appreciate the detail!

scrthq commented 5 years ago

@WJurecki - Fields is working correctly now:

image

with default behavior untouched and still picking up the default value for Projection:

image

yes

scrthq commented 5 years ago

Hey @WJurecki - This has been deployed in v2.28.0! Let me know if all is well or if you are seeing any issues!

WJurecki commented 5 years ago

Hey @scrthq - This works great. Thanks!

scrthq commented 5 years ago

You bet @WJurecki !!