Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom types with dynamic columns in select statement #1010

Open
nomoney4me opened this issue Jan 12, 2025 · 0 comments
Open

Custom types with dynamic columns in select statement #1010

nomoney4me opened this issue Jan 12, 2025 · 0 comments

Comments

@nomoney4me
Copy link

nomoney4me commented Jan 12, 2025

I am currently doing something like this (https://github.com/porsager/postgres?tab=readme-ov-file#dynamic-column-selection) and is seeing the same issue mentioned in #161. I added https://github.com/porsager/postgres?tab=readme-ov-file#custom-types but can't see how I can make it work with my select statement as the columns are in an array.

Does anyone have a sample piece of code that they have working to get the timestamp as a string using dynamic column in a select statement? Here is a simple example of what I'm trying to do:

var cols = ['id', 'name', 'last_created'];
var result = sql`select ${sql(cols)} from members`;

/* expecting: 
[ 
	{ 
		id: 1, 
		name: "john", 
		last_created: "2023-09-11T00:00:00.000Z"
	}
] 
*/

Thank you in advance.

@nomoney4me nomoney4me changed the title Custom types with dynamic columns Custom types with dynamic columns in select statement Jan 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant