TEAMSchools / powerschool

API client for PowerSchool
GNU General Public License v3.0
19 stars 4 forks source link

Table names are... partially case-sensitive #24

Open pjpiwowarski opened 2 years ago

pjpiwowarski commented 2 years ago

There's some fairly weird behavior when trying to access tables with non-lowercase names. For example (where ps() returns a PowerSchool() instance):

>>> ps().get_schema_table('GradeScaleItem').query()
[None, None, None, ... (one for each row in GradeScaleItem)]

This appears to be happening because, while PowerSchool smiles tolerantly and returns the results you'd expect, the keys in its response are still all lowercase, as in:

{
    'name': 'GradeScaleItem',
    'record': [
        {
            'id': 1, 
            'tables': {'gradescaleitem': { (record keys/values) }}
        },
        ...
    ]
}

As a result, the second get() call at client.py:243 fails to find a match and returns None (because self.name differs from the result's value in case):

data.append(r.get("tables").get(self.name))

Whether this should be "fixed" by case-smashing the table name (self.name.lower() or so) and/or the keys in the result, or just documented in the future (when there exists documentation), I don't know.

cbini commented 2 years ago

good catch!

have you also encountered this with other tables? also, have you encountered this in the opposite direction? (i.e. table.name is lowercase but record.tables.name is mixed case)

pjpiwowarski commented 2 years ago

I haven't had occasion to do extensive testing of that sort, no, mainly because I very seldom actually want records straight from a table (as opposed to a PowerQuery).

On Wed, Feb 23, 2022, 3:22 PM Charlie Bini @.***> wrote:

good catch!

have you also encountered this with other tables? also, have you encountered this in the opposite direction? (i.e. table.name is lowercase but record.tables.name is mixed case)

— Reply to this email directly, view it on GitHub https://github.com/TEAMSchools/powerschool/issues/24#issuecomment-1049180136, or unsubscribe https://github.com/notifications/unsubscribe-auth/AXMRG3NACWZVXM6KHAVORS3U4U6X5ANCNFSM5PFLEKMA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you authored the thread.Message ID: @.***>