-
Notifications
You must be signed in to change notification settings - Fork 67
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
dbtoyaml - analyze view columns data types #184
Comments
I suppose my team can prepare patch for that. |
My response to this is more or less the same as for #183, except that it should be easier to fetch the view column information from |
BTW, on my system (PG 9.6.7), the third column of the view is named |
@jmafc yes, sorry, copy-pasted wrong sql file. |
I don't see where it would be possible to extract the information for the
|
Seems like psql in some way detect view datatypes, and it's possible to investigate it from pyrseas without analyzing the columns expessions |
So, I understand your position described in #183 and in general can agree. We can easy extend this output, but in result we need to fork pyrseas or make some extra queries to postgresql after dbtoyaml run. Would be very great extract this information and include it to yaml file. |
Oleg, psql gets its type info from |
@jmafc Oh, now got it. You will include this information to dbtoyaml output. |
I have started to create a ViewToMapTestCase based on your example (except using table/view names view v1:
definition: |2-
SELECT (ROW(t1.c1)::public.t2).c2 AS c2,
t1.*::public.t1 AS t1,
5 AS const
FROM public.t1;
depends_on:
- table t1 Looking at your "desired output" however, I think we should only output the data types for the columns, i.e., columns:
- c2:
type: integer
- t1:
type: t1
- const:
type: integer That is, we will not include those |
@jmafc yes, that's good! |
@tbussmann @rhunwicks @dvarrazzo Pyrseas/pyrseas/dbobject/column.py Line 81 in 7c1a1f9
Pyrseas/pyrseas/dbobject/view.py Line 84 in 7c1a1f9
However, although the view column datatype info may be, well, informative, it seems to me that it serves no purpose in the SQL generation side of things. IOW, if we read in 'view': 'columns' in yamltodb we'll either discard it (or carry it along but it's deadweight). If we decide to continue with the implementation of this feature, we'd have to extend it to materialized views (relkind = 'm' ) (Roger, that's why I added you--at some point, you had a special interest in matviews), and unless its output is made optional, we'd have to change ALL view and matview tests (25), and functional tests, for very little gain IMHO.Therefore, I'm asking for second opinions on the desirability of implementing this. |
@jmafc sometime happens, when some good solution planned for one thing unexpectedly usable for another scenario. Actual world of web programming widely covered by ORM which generated SQL code from general-purpose language, but about zero projects with opposite direction - generate general-purpose language code from SQL. Single exception is https://github.com/begriffs/postgrest but it's too radical - direct connection from client/browser. dbtoyaml covers this lack, and provide type information about columns for view is very usefull. |
Oleg, my point in questioning the usefulness of this feature is that although, as you say, "dbtoyaml covers this lack", that's not what |
Would be very nice to see the view columns data types.
Example:
actual output:
desired output:
or something like that
The text was updated successfully, but these errors were encountered: