Introspecting FK

Forum for posting problems using QxOrm library

Introspecting FK

Postby gianks » Sat Aug 13, 2016 5:07 pm

Hi,
i'm using introspection on relationships but i'm unable to retrieve informations about the party table.
The qx::IxSqlRelation instance i'm retrieving via getSqlRelation seems to be incomplete on purpose since in the debugger i can see the parameter TraceRelationInIt = false.

How can i obtain the referenced table as a IxDataMember to finally obtain the table name and id info?

Thanks
gianks
 
Posts: 45
Joined: Mon Jul 04, 2016 1:04 pm

Re: Introspecting FK

Postby qxorm » Tue Aug 16, 2016 7:42 am

Hello,

How can i obtain the referenced table as a IxDataMember to finally obtain the table name and id info?


To have an example, you can take a look at the qx::QxSqlRelation_OneToMany class source code.
For example :
Code: Select all
IxDataMember * pId = this->getDataId();
IxDataMember * pForeign = this->getDataByKey(this->m_sForeignKey);

Replace this by your qx::IxSqlRelation instance.

in the debugger i can see the parameter TraceRelationInIt = false

If you want to enable this log, just write :
Code: Select all
qx::IxSqlRelation::setTraceRelationInit(true);
qxorm
Site Admin
 
Posts: 481
Joined: Mon Apr 12, 2010 7:45 am

Re: Introspecting FK

Postby gianks » Mon Aug 22, 2016 7:52 pm

Hi and thanks for the reply,
unfortunately m_sForeignKey is protected and i don't see any getter... am i wrong?

EDIT: checking with debugger seems that the member you suggested is NULL, like almost everything in the relation, see below the dump of the live object:
pRelation 0xe90d00
qx::QxPropertyBag {...}
m_pClass 0x0
m_pClassOwner 0x0
m_pDataMember 0xe90b60
m_pDataMemberX 0x0
m_pDataMemberId 0x0
m_pDataMemberIdOwner 0x0
m_lOffsetRelation 100
m_eJoinType qx::dao::sql_join::left_outer_join
m_eRelationType qx::IxSqlRelation::many_to_one
m_oSoftDelete {...}
m_sForeignKey {...}
null {...}
d 0x7ffff647e6e0 <QArrayData::shared_null>
QArrayData {...}
m_sExtraTable {...}
m_sForeignKeyOwner {...}
m_sForeignKeyDataType {...}
m_lstDataMemberPtr 0x0
m_lstSqlRelationPtr 0x0
m_bTraceRelationInit false

:shock: any idea?
gianks
 
Posts: 45
Joined: Mon Jul 04, 2016 1:04 pm

Re: Introspecting FK

Postby qxorm » Tue Aug 23, 2016 9:47 am

unfortunately m_sForeignKey is protected and i don't see any getter... am i wrong?

Yes, you are right, I will add some getters in the qx::IxSqlRelation class.

checking with debugger seems that the member you suggested is NULL, like almost everything in the relation

It seems that your relation has not been initialized.
Just call this line to initialize your relation :
Code: Select all
pRelation->init();
qxorm
Site Admin
 
Posts: 481
Joined: Mon Apr 12, 2010 7:45 am

Re: Introspecting FK

Postby gianks » Tue Aug 23, 2016 3:18 pm

Calling init() did the trick!
No more getters are needed in my opinion since the nested pointers structure offered by IxClass, IxDataMember and IxSqlRelation is fully traversable after that.

Probably they would just be a surplus ;)

Thanks
gianks
 
Posts: 45
Joined: Mon Jul 04, 2016 1:04 pm

Re: Introspecting FK

Postby qxorm » Wed Aug 24, 2016 7:26 am

Calling init() did the trick!

Great !
qxorm
Site Admin
 
Posts: 481
Joined: Mon Apr 12, 2010 7:45 am


Return to QxOrm - Help

Who is online

Users browsing this forum: No registered users and 3 guests