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

add mapping for text search types #31

Closed
abenhamdine opened this issue Jan 11, 2017 · 4 comments
Closed

add mapping for text search types #31

abenhamdine opened this issue Jan 11, 2017 · 4 comments

Comments

@abenhamdine
Copy link
Contributor

abenhamdine commented Jan 11, 2017

A powerfull feature in postgres is the full text search, which can be perfectly used as a replacement of nosql similar features (elastic search, etc).

For this, postgres provides several types :

  • tsquery
  • tsvector
  • tsrange

see https://www.postgresql.org/docs/current/static/datatype-textsearch.html

The udt names are the sames as the postgres type names :

SELECT column_name, udt_name
            FROM information_schema.columns
            WHERE table_name = 'test' and table_schema = 'public'

gives

image

I don't know exactly which typescript type to map to these types, as usually theses types are manipulated with built-in functions/casts, like ::tsvector or to_tsvector and can not be inserted like simple strings.

Perhaps the any type is the most appropriate for this ?

@xiamx
Copy link
Contributor

xiamx commented Jan 11, 2017

I'm not really sure how to deal with this. If pg does not provide a typecast for it, then it's safe to give it an any type.

@abenhamdine
Copy link
Contributor Author

All things considered, wouldn't it be better to map any for any unknown type ? Because it's likely that we miss some valid types in the mapping (this time it's tsvector, next time it will be veryRarePgTypeButValidOne, etc...).

What you think about returning any for any unrecognized type in the mapping, and print a warning in the console (eg : Warning : type foo is unknown and will be mapped with any type) ?

@xiamx
Copy link
Contributor

xiamx commented Jan 12, 2017

Yup let's do that.

@vitaly-t
Copy link
Contributor

Yes, it is much better for an unknown type to generate type any, and show a warning, rather than just throw an error and stop.

@xiamx xiamx closed this as completed in a0499fe Jan 16, 2017
xiamx added a commit that referenced this issue Jan 16, 2017
Add support for nullable types, map any as default type : fix #19, fix #31
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

3 participants