File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -121,7 +121,14 @@ Table.prototype.getName = function() {
121121 return this . _name ;
122122} ;
123123
124- Table . prototype . star = function ( ) {
124+ Table . prototype . star = function ( options ) {
125+ options = options || { } ;
126+ if ( options . prefix ) {
127+ return this . columns . map ( function ( column ) {
128+ return this [ column . name ] . as ( options . prefix + column . name ) ;
129+ } . bind ( this ) ) ;
130+ }
131+
125132 return new Column ( { table : this , star : true } ) ;
126133} ;
127134
Original file line number Diff line number Diff line change @@ -54,6 +54,23 @@ Harness.test({
5454 params : [ ]
5555} ) ;
5656
57+ Harness . test ( {
58+ query : user . select ( user . star ( { prefix : 'foo_' } ) ) . from ( user ) ,
59+ pg : {
60+ text : 'SELECT "user"."id" AS "foo_id", "user"."name" AS "foo_name" FROM "user"' ,
61+ string : 'SELECT "user"."id" AS "foo_id", "user"."name" AS "foo_name" FROM "user"'
62+ } ,
63+ sqlite : {
64+ text : 'SELECT "user"."id" AS "foo_id", "user"."name" AS "foo_name" FROM "user"' ,
65+ string : 'SELECT "user"."id" AS "foo_id", "user"."name" AS "foo_name" FROM "user"'
66+ } ,
67+ mysql : {
68+ text : 'SELECT `user`.`id` AS `foo_id`, `user`.`name` AS `foo_name` FROM `user`' ,
69+ string : 'SELECT `user`.`id` AS `foo_id`, `user`.`name` AS `foo_name` FROM `user`'
70+ } ,
71+ params : [ ]
72+ } ) ;
73+
5774Harness . test ( {
5875 query : user . select ( user . id ) . from ( user ) . where ( user . name . equals ( 'foo' ) ) ,
5976 pg : {
You can’t perform that action at this time.
0 commit comments