( pgClient: Client, schemaName: string, chainId: string | undefined, useRowEst: boolean )
| 133 | let defaultMetadataName: string; |
| 134 | |
| 135 | export async function fetchFromTable( |
| 136 | pgClient: Client, |
| 137 | schemaName: string, |
| 138 | chainId: string | undefined, |
| 139 | useRowEst: boolean |
| 140 | ): Promise<MetaData> { |
| 141 | let metadataTableName: string; |
| 142 | |
| 143 | if (!chainId) { |
| 144 | // return first metadata entry you find. |
| 145 | if (defaultMetadataName === undefined) { |
| 146 | const {rows} = await pgClient.query( |
| 147 | `SELECT table_name FROM information_schema.tables where table_schema='${schemaName}'` |
| 148 | ); |
| 149 | const {table_name} = rows.find((obj: {table_name: string}) => matchMetadataTableName(obj.table_name)); |
| 150 | defaultMetadataName = table_name; |
| 151 | } |
| 152 | metadataTableName = defaultMetadataName; |
| 153 | } else { |
| 154 | metadataTableName = getMetadataTableName(chainId); |
| 155 | } |
| 156 | |
| 157 | return fetchMetadataFromTable(pgClient, schemaName, metadataTableName, useRowEst); |
| 158 | } |
| 159 | |
| 160 | function metadataTableSearch(build: Build): boolean { |
| 161 | return !!(build.pgIntrospectionResultsByKind as PgIntrospectionResultsByKind).attribute.find((attr) => |
no test coverage detected