-
Notifications
You must be signed in to change notification settings - Fork 3
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
Type error on field #21
Comments
So I was able to get through that specific error by making some changes to the types: AirtableOneOfType = th.OneOf(
th.StringType,
th.NumberType,
th.BooleanType,
th.DateTimeType,
th.DateType,
)
AirtableAnyType = th.OneOf(
AirtableOneOfType,
th.ArrayType(AirtableOneOfType),
) Then in "formula": AirtableAnyType, I then had the same error on "lookup" so did that too: "lookup": AirtableAnyType, Still having some problems, but getting somewhere. If you take a look at the typescript types for fields, it's pretty chaotic -- and basically in Airtable it does seem like a lot of these fields can be things other than strings (in my case, formulas and lookups were actually numbers): export interface FieldSet {
[key: string]: undefined | string | number | boolean | Collaborator | ReadonlyArray<Collaborator> | ReadonlyArray<string> | ReadonlyArray<Attachment>;
} I think the solution here is either:
Or something else haha. |
I ended up making a few more changes to get things working on my end.
th.Property(
"exclude",
th.ObjectType(
additional_properties=th.ObjectType(
additional_properties=th.ArrayType(th.StringType)
)
),
description="Exclude fields from specific tables in bases",
required=False,
) which looks like this (the slugified version of the column name): config:
exclude:
base_id:
table_id:
- field_name1
- field_name2 and then I had to continue to keep making changes in types.py, these are the updates I ended up making: AirtableCollaborator = th.ObjectType(
th.Property("id", th.StringType),
th.Property("email", th.StringType),
th.Property("name", th.StringType),
th.Property("permissionLevel", th.StringType),
th.Property("profilePicUrl", th.StringType),
)
AirtableButtonType = th.ObjectType(
th.Property("label", th.StringType),
th.Property("url", th.StringType),
)
AirtableOneOfType = th.OneOf(
th.StringType,
th.NumberType,
th.BooleanType,
th.DateTimeType,
th.DateType,
th.ArrayType(th.StringType),
th.ArrayType(th.NumberType),
th.ArrayType(th.BooleanType),
th.ArrayType(th.DateTimeType),
th.ArrayType(th.DateType),
)
AirtableAnyType = th.OneOf(
AirtableOneOfType,
th.ArrayType(AirtableOneOfType),
)
AIRTABLE_TO_SINGER_MAPPING: dict[str, Any] = {
"singleLineText": th.StringType,
"email": th.StringType,
"url": th.StringType,
"multilineText": th.StringType,
"number": th.NumberType,
"percent": th.OneOf(th.StringType, th.NumberType),
"currency": th.OneOf(th.StringType, th.NumberType),
"singleSelect": th.StringType,
"multipleSelects": th.ArrayType(th.StringType),
"singleCollaborator": AirtableCollaborator,
"multipleCollaborators": th.ArrayType(AirtableCollaborator),
"multipleRecordLinks": th.ArrayType(AirtableAnyType),
"date": th.DateType,
"dateTime": th.DateTimeType,
"phoneNumber": th.StringType,
"multipleAttachments": th.ArrayType(AirtableAttachment),
"checkbox": th.BooleanType,
"formula": AirtableAnyType,
"createdTime": th.DateTimeType,
"rollup": AirtableAnyType,
"count": AirtableAnyType,
"lookup": AirtableAnyType,
"multipleLookupValues": th.ArrayType(AirtableOneOfType),
"autoNumber": th.OneOf(th.StringType, th.NumberType),
"barcode": th.StringType,
"rating": th.StringType,
"richText": th.StringType,
"duration": th.StringType,
"lastModifiedTime": th.DateTimeType,
"button": AirtableButtonType,
"createdBy": AirtableCollaborator,
"lastModifiedBy": th.StringType,
"externalSyncSource": th.StringType,
"aiText": th.StringType,
} I know this is quite a bit of changes, so I won't directly open a PR right now. Happy to open a PR if anyone else runs into these problems. |
Hey @lukevers, thanks a lot for posting this! TBH I haven't tried anything with formulas yet, so it's just natural it doesn't work out of the box and I'm glad you've found this issue. Since, if I understand correctly, formula can output almost anything, would it be sufficient to type formulas as Any type in JSON schema? |
Hey,
I was testing this out and ran into an issue. I have a field in airtable that is a formula and returns a number. It looks like it's mad it's not a string (and was not cast to a string):
Here are my logs:
The text was updated successfully, but these errors were encountered: