Skip to content

computed fields breaking studio #2862

Description

@lombo75

Description and expected behavior
Yes, this appears to be a ZenStack Studio limitation/bug.

Your computed fields work perfectly at the API level (we proved this), but Studio's proxy runtime doesn't have access to the SQL implementations in computedFields.ts, so it can't display them.

What's Working ✅
Computed field definitions in schema
SQL resolver implementations
API queries return correct values
Application runtime has everything it needs
What's Not Working ❌
Studio UI proxy - can't resolve computed fields
Studio tables for Bid, BidSubmission, Project, Opportunity models
Recommendation
Since the API works perfectly and that's what your app uses, this is safe to ignore for now. If you need to browse data with computed fields:

Use the test script: pnpm run test:computed-fields
Or query the API directly
Studio's lack of computed field display is a presentation issue, not a data issue
Consider reporting this to ZenStack if you haven't already - they should support computed fields in Studio.
Screenshots

Image

Environment (please complete the following information):

  • ZenStack version: [e.g., 3.9.7]
  • Database type: Postgresql
  • Node.js/Bun version: v26.8.2
  • Package manager: pnpm

Additional context

I am writing computed fields like this as kysely doesnt work

// The baseTotalPrice is a computed field that calculates the total price of the bid based on the related estimates. It sums up the product of quantity and unitPrice for all EstimateLineItems associated with the bid, providing a dynamic calculation of the bid's total value. Returns 0 if no estimates exist.
baseTotalPrice: (_eb, { modelAlias }) => {
const bidIdRef = sql.ref(${modelAlias}.id)

  return sql<number>`COALESCE((
    SELECT COALESCE(SUM("EstimateLineItem"."quantity" * "EstimateLineItem"."unitPrice"), 0)
    FROM "EstimateLineItem"
    INNER JOIN "Estimate" ON "EstimateLineItem"."estimateId" = "Estimate"."id"
    WHERE "Estimate"."bidId" = ${bidIdRef}
  ), 0)`
},

No activity

Activity on this issue will appear here.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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