Not able to See SQL VIEWS with stored functions

Hi Team,
I have created a view in postgresSQL (which uses some stored functions) and have created a corresponding model for that with the help of ‘scenic’ gem.

I am able to access the model via rails console. But I am not able to see that model in the forest admin UI. It throws the below error.

NOTE: I don’t see any errors in the rails server console.

Please help me to rectify this issue.

Regards,
Ajith Mani V.
Project : PlutusAdmin

Hi @ajithmani,

Can you please confirm than other collections in this project are working?
What is the name of the failing collection?
Also, can you share the model for this collection?
Also, do you have some logs on your server (indicating a 404 maybe) and in your browser?

Regards

Hi @Sliman_Medini ,
Yeah it is working for other collections. It is not working only for this particular VIEW.
The collection name is ‘IncorrectInstrumentDetail’
The model name is also the same.
I don’t see any logs in my browers as well as server indicating an error code.
They shows only status_code 200;

Regards,
Ajith Mani

Hello @ajithmani,

Could you also check the “network” tab in your browser developer tools?
Given you screenshot, some request should be in error.

Thank you

Hi @anon79585656,
Sorry, I was seeing only xhr requests before.
I am getting 404 error for this url
https://www.gravatar.com/avatar/efffac4a5c67af153e74c8ab4f3ba681?s=80&d=404

Regards,
Ajith Mani

@ajithmani,

Provided your model is called “mymodel”, you should see a call to an URL like http://your.server/forest/mymodel.

Could you please paste the request details and its full response? To see if this is an issue with the data format.

Thank you.

@anon79585656
These are the api details.

Request Details
URL :

 GET /forest/IncorrectInstrumentDetail?timezone=Asia%2FCalcutta&fields%5BIncorrectInstrumentDetail%5D=category%2Ccoupon_rate%2Ccredit_rating%2Ccredit_rating_agency%2Cface_value%2Cinstrument_id%2Cinterest_payment_frequency%2Cis_tax_free%2Cisin%2Cissuance_type%2Cmaturity_date&page%5Bnumber%5D=1&page%5Bsize%5D=15&searchExtended=0 HTTP/1.1

Query Parameters

fields%5BIncorrectInstrumentDetail%5D: category%2Ccoupon_rate%2Ccredit_rating%2Ccredit_rating_agency%2Cface_value%2Cinstrument_id%2Cinterest_payment_frequency%2Cis_tax_free%2Cisin%2Cissuance_type%2Cmaturity_date
searchExtended: 0
timezone: Asia%2FCalcutta

Response Details
status-code: 200

{
  "data": [
    {
      "type": "IncorrectInstrumentDetail",
      "attributes": {
        "isin": "INE881J08136",
        "instrument_id": 89102,
        "coupon_rate": false,
        "credit_rating": true,
        "interest_payment_frequency": false,
        "category": false,
        "face_value": true,
        "maturity_date": false,
        "is_tax_free": false,
        "issuance_type": false,
        "credit_rating_agency": false
      },
      "links": {
        "self": "/forest/incorrect_instrument_detail/"
      }
    },
    {
      "type": "IncorrectInstrumentDetail",
      "attributes": {
        "isin": "INE848E07BN4",
        "instrument_id": 89784,
        "coupon_rate": false,
        "credit_rating": true,
        "interest_payment_frequency": false,
        "category": false,
        "face_value": false,
        "maturity_date": false,
        "is_tax_free": true,
        "issuance_type": false,
        "credit_rating_agency": false
      },
      "links": {
        "self": "/forest/incorrect_instrument_detail/"
      }
    },
    {
      "type": "IncorrectInstrumentDetail",
      "attributes": {
        "isin": "INE001A07RK0",
        "instrument_id": 90279,
        "coupon_rate": false,
        "credit_rating": true,
        "interest_payment_frequency": false,
        "category": false,
        "face_value": true,
        "maturity_date": false,
        "is_tax_free": false,
        "issuance_type": false,
        "credit_rating_agency": true
      },
      "links": {
        "self": "/forest/incorrect_instrument_detail/"
      }
    },
    {
      "type": "IncorrectInstrumentDetail",
      "attributes": {
        "isin": "INE851M07101",
        "instrument_id": 98536,
        "coupon_rate": true,
        "credit_rating": true,
        "interest_payment_frequency": true,
        "category": true,
        "face_value": true,
        "maturity_date": true,
        "is_tax_free": true,
        "issuance_type": true,
        "credit_rating_agency": true
      },
      "links": {
        "self": "/forest/incorrect_instrument_detail/"
      }
    },
    {
      "type": "IncorrectInstrumentDetail",
      "attributes": {
        "isin": "INE434K07027",
        "instrument_id": 136303,
        "coupon_rate": false,
        "credit_rating": true,
        "interest_payment_frequency": false,
        "category": false,
        "face_value": false,
        "maturity_date": true,
        "is_tax_free": false,
        "issuance_type": false,
        "credit_rating_agency": false
      },
      "links": {
        "self": "/forest/incorrect_instrument_detail/"
      }
    },
    {
      "type": "IncorrectInstrumentDetail",
      "attributes": {
        "isin": "INE572O07GP3",
        "instrument_id": 137433,
        "coupon_rate": false,
        "credit_rating": false,
        "interest_payment_frequency": false,
        "category": true,
        "face_value": false,
        "maturity_date": false,
        "is_tax_free": false,
        "issuance_type": true,
        "credit_rating_agency": false
      },
      "links": {
        "self": "/forest/incorrect_instrument_detail/"
      }
    },
    {
      "type": "IncorrectInstrumentDetail",
      "attributes": {
        "isin": "INE649M07026",
        "instrument_id": 254912,
        "coupon_rate": false,
        "credit_rating": false,
        "interest_payment_frequency": false,
        "category": false,
        "face_value": true,
        "maturity_date": false,
        "is_tax_free": true,
        "issuance_type": false,
        "credit_rating_agency": false
      },
      "links": {
        "self": "/forest/incorrect_instrument_detail/"
      }
    },
    {
      "type": "IncorrectInstrumentDetail",
      "attributes": {
        "isin": "INE572J07372",
        "instrument_id": 298590,
        "coupon_rate": true,
        "credit_rating": false,
        "interest_payment_frequency": true,
        "category": false,
        "face_value": true,
        "maturity_date": false,
        "is_tax_free": true,
        "issuance_type": true,
        "credit_rating_agency": true
      },
      "links": {
        "self": "/forest/incorrect_instrument_detail/"
      }
    }
  ],
  "included": []
}

Let me know if it is not clear.

Regards,
Ajith Mani

@ajithmani,

Thank you for the details.

I do not see any obvious issue, but as you have:

  • status-code 200
  • data in the response
  • the “cannot reach your data” error

I am pretty sure there is an issue with the data formatting.

That message is not the good one, and I’ll create an issue with the dev team.

But I can reproduce this when I have a 200 status and no, or no valid, record in the response.

Can you try to add another very simple view to your DB and the corresponding model to your project to see if this error persists?
One with only a string field should suffice. Try to add an id column if the error is still there.

Thank you.

@anon79585656
I have tried creating views with simple data_fields like id and name from a table.
It was working properly.

But it was not working for views which use stored functions.

Thanks
Ajith mani

Hi @anon79585656
I have also tried to create another view named “incorrect_fields” which uses array_agg() function in it.
It also throws the same error.

I think using that function causes the error. Could you please confirm?

Regards,
Ajith mani