Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@malloydata/db-postgres

Package Overview
Dependencies
Maintainers
3
Versions
1156
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@malloydata/db-postgres - npm Package Compare versions

Comparing version 0.0.11-dev221202152346 to 0.0.11-dev221202180154

13

dist/postgres_connection.d.ts

@@ -1,2 +0,2 @@

import { FetchSchemaAndRunSimultaneously, FetchSchemaAndRunStreamSimultaneously, PersistSQLResults, RunSQLOptions, StreamingConnection, StructDef, MalloyQueryData, QueryData, PooledConnection, SQLBlock, Connection, QueryDataRow } from "@malloydata/malloy";
import { PersistSQLResults, RunSQLOptions, StreamingConnection, StructDef, MalloyQueryData, QueryData, PooledConnection, SQLBlock, Connection, QueryDataRow } from "@malloydata/malloy";
import { Client } from "pg";

@@ -27,4 +27,2 @@ interface PostgresQueryConfiguration {

canPersist(): this is PersistSQLResults;
canFetchSchemaAndRunSimultaneously(): this is FetchSchemaAndRunSimultaneously;
canFetchSchemaAndRunStreamSimultaneously(): this is FetchSchemaAndRunStreamSimultaneously;
canStream(): this is StreamingConnection;

@@ -35,5 +33,8 @@ fetchSchemaForTables(missing: string[]): Promise<{

}>;
fetchSchemaForSQLBlocks(sqlRefs: SQLBlock[]): Promise<{
schemas: Record<string, StructDef>;
errors: Record<string, string>;
fetchSchemaForSQLBlock(sqlRef: SQLBlock): Promise<{
structDef: StructDef;
error?: undefined;
} | {
error: string;
structDef?: undefined;
}>;

@@ -40,0 +41,0 @@ protected getClient(): Promise<Client>;

@@ -51,2 +51,3 @@ "use strict";

const pg_query_stream_1 = __importDefault(require("pg-query-stream"));
const crypto_1 = require("crypto");
const postgresToMalloyTypes = {

@@ -113,9 +114,2 @@ "character varying": "string",

}
canFetchSchemaAndRunSimultaneously() {
// TODO feature-sql-block Implement FetchSchemaAndRunSimultaneously
return false;
}
canFetchSchemaAndRunStreamSimultaneously() {
return false;
}
canStream() {

@@ -149,27 +143,17 @@ return true;

}
async fetchSchemaForSQLBlocks(sqlRefs) {
const schemas = {};
const errors = {};
for (const sqlRef of sqlRefs) {
const key = sqlRef.name;
let inCache = this.sqlSchemaCache.get(key);
if (!inCache) {
try {
inCache = {
schema: await this.getSQLBlockSchema(sqlRef),
};
this.schemaCache.set(key, inCache);
}
catch (error) {
inCache = { error: error.message };
}
async fetchSchemaForSQLBlock(sqlRef) {
const key = sqlRef.name;
let inCache = this.sqlSchemaCache.get(key);
if (!inCache) {
try {
inCache = {
structDef: await this.getSQLBlockSchema(sqlRef),
};
}
if (inCache.schema !== undefined) {
schemas[key] = inCache.schema;
catch (error) {
inCache = { error: error.message };
}
else {
errors[key] = inCache.error;
}
this.sqlSchemaCache.set(key, inCache);
}
return { schemas, errors };
return inCache;
}

@@ -217,8 +201,7 @@ async getClient() {

};
// TODO -- Should be a uuid
const tempTableName = `malloy${Math.floor(Math.random() * 10000000)}`;
const tempTableName = `tmp${(0, crypto_1.randomUUID)()}`.replace(/-/g, "");
const infoQuery = `
drop table if exists ${tempTableName};
create temp table ${tempTableName} as SELECT * FROM (
${sqlRef.select}
${sqlRef.selectStr}
) as x where false;

@@ -225,0 +208,0 @@ SELECT column_name, c.data_type, e.data_type as element_type

{
"name": "@malloydata/db-postgres",
"version": "0.0.11-dev221202152346",
"version": "0.0.11-dev221202180154",
"license": "GPL-2.0",

@@ -21,3 +21,3 @@ "main": "dist/index.js",

"dependencies": {
"@malloydata/malloy": "^0.0.11-dev221202152346",
"@malloydata/malloy": "^0.0.11-dev221202180154",
"@types/pg": "^8.6.1",

@@ -24,0 +24,0 @@ "pg": "^8.7.1",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc