Skip to content

TypeScript / React useTable returns number instead of bool #4591

@sean256

Description

@sean256

View

export const foo = db.view(
	{ name: 'foo', public: true },
	t.array(t.row('fooReturns', { foo: t.bool() })),
	ctx => {
		return [
			{
				foo: true,
			},
		];
	},
);

Output via React useTable

Actual

{"foo":1}

Expected

{"foo":true}

Output via SQL Endpoint

[
  {
    "schema": {
      "elements": [
        {
          "name": {
            "some": "foo"
          },
          "algebraic_type": {
            "Bool": []
          }
        }
      ]
    },
    "rows": [
      [
        true
      ]
    ],
    "total_duration_micros": 2927,
    "stats": {
      "rows_inserted": 0,
      "rows_deleted": 0,
      "rows_updated": 0
    }
  }
]

Weirdly this half works

export const foo = db.view(
	{ name: 'foo', public: true },
	t.array(t.row('fooReturns', { foo: t.bool(), sub: t.object('foo', { subFoo: t.bool() }) })),
	ctx => {
		return [
			{
				foo: true,
				sub: {
					subFoo: true,
				},
			},
		];
	},
);

OUTPUT

{"foo":true,"sub":{"subFoo":1}}

Now the top level value is correctly a bool, but the sub value is a number

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions