QB missing addPk() with other columns

Questions and answers on designing your Servoy solutions, database modelling and other 'how do I do this' that don't fit in any of the other categories

QB missing addPk() with other columns

Postby huber » Fri Apr 28, 2017 3:15 pm

Hi All

Concerning a Query Builder statement, mixing addPk() in addition to other columns (even from joined tables) should work ok, is it?

Code: Select all
         var query = datasources.db.hades.profile_definitions.createSelect();
         var pd = query.columns;
         query.result
            .addPk()
            .add(pd.assessment_code_exam_mark)
            .add(a.discriminator);
         /** @type {QBJoin<db:/hades/assessments>} */
         var join = query.joins.add('db:/hades/assessments', JSRelation.LEFT_OUTER_JOIN);
         var a = join.columns;
         join.on
            .add(pd.assessment_code_exam_mark.eq(a.code));
         query.where
            .add(pd.level_number.eq(datasetExamSubjects.getValue(j, 4)))

Regards,
Robert Huber
7r AG, Switzerland
SAN Developer
http://www.seven-r.ch
User avatar
huber
 
Posts: 518
Joined: Mon May 14, 2012 11:31 pm

Re: QB missing addPk() with other columns

Postby patrick » Fri Apr 28, 2017 4:36 pm

Yes.

I think your code should throw an error though. You declare "a" after you use it in the result. In general I think it is always easiest to simply test stuff :o . When it comes to queries, I always find it very easy to verify what goes by putting a breakpoint before the query is actually fired, then go to servoy-admin/database-performance, clear that, step over the breakpoint and then simply look at the query that is printed in database-performance.
Patrick Ruhsert
Servoy DACH
patrick
 
Posts: 3703
Joined: Wed Jun 11, 2003 10:33 am
Location: Munich, Germany

Re: QB missing addPk() with other columns

Postby huber » Wed May 10, 2017 12:15 pm

I agree testing is necessary, but I also like to know how something is intended by Servoy. Thanks for the tip.

Regards,
Robert Huber
7r AG, Switzerland
SAN Developer
http://www.seven-r.ch
User avatar
huber
 
Posts: 518
Joined: Mon May 14, 2012 11:31 pm


Return to Programming with Servoy

Who is online

Users browsing this forum: No registered users and 13 guests

cron