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

Make classIdsToClassNames explicit parameter independent of UseJsPropertyName #883

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions iModelCore/ECDb/ECDb/BuiltInFuncs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ void ExtractPropFunc::_ComputeScalar(Context& ctx, int nArgs, DbValue* args) {

InstanceReader::JsonParams params;
params.SetUseJsName(jsonFlags & InstanceReader::FLAGS_UseJsPropertyNames);
params.SetClassIdToClassNames(jsonFlags & InstanceReader::FLAGS_ClassIdsToClassNames);
params.SetAbbreviateBlobs(!(jsonFlags & InstanceReader::FLAGS_DoNotTruncateBlobs));

const auto json = row.GetJson(params).Stringify();
Expand Down Expand Up @@ -157,6 +158,7 @@ void ExtractInstFunc::_ComputeScalar(Context& ctx, int nArgs, DbValue* args) {

InstanceReader::JsonParams params;
params.SetUseJsName(jsonFlags & InstanceReader::FLAGS_UseJsPropertyNames);
params.SetClassIdToClassNames(jsonFlags & InstanceReader::FLAGS_ClassIdsToClassNames);
params.SetAbbreviateBlobs(!(jsonFlags & InstanceReader::FLAGS_DoNotTruncateBlobs));

auto setResult = [&](InstanceReader::IRowContext const& row){
Expand Down Expand Up @@ -735,7 +737,7 @@ void XmlCAToJson::_ComputeScalar(Context& ctx, int nArgs, DbValue* args)
}

DbValue const& idValue = args[0];
if (idValue.IsNull() || idValue.GetValueType() != DbValueType::IntegerVal)
if (idValue.IsNull() || idValue.GetValueType() != DbValueType::IntegerVal)
{
ctx.SetResultNull();
return;
Expand All @@ -750,7 +752,7 @@ void XmlCAToJson::_ComputeScalar(Context& ctx, int nArgs, DbValue* args)
}

DbValue const& xmlValue = args[1];
if (xmlValue.IsNull() || xmlValue.GetValueType() != DbValueType::TextVal)
if (xmlValue.IsNull() || xmlValue.GetValueType() != DbValueType::TextVal)
{
ctx.SetResultNull();
return;
Expand Down
32 changes: 16 additions & 16 deletions iModelCore/ECDb/ECDb/ECSql/ECSqlPreparer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ ECSqlStatus ECSqlExpPreparer::InsertSubquery(ECSqlPrepareContext& ctx, AllOrAnyE
{
case SqlCompareListType::All:
{

for (Exp const* childExp : subquerySelect.GetSelection()->GetChildren())
{
if (!isFirstItem)
Expand Down Expand Up @@ -212,7 +212,7 @@ ECSqlStatus ECSqlExpPreparer::InsertSubquery(ECSqlPrepareContext& ctx, AllOrAnyE
allOrAnyQuery.AppendParenRight();
break;
}

case SqlCompareListType::Any:
case SqlCompareListType::Some:
{
Expand Down Expand Up @@ -1892,7 +1892,7 @@ ECSqlStatus ECSqlExpPreparer::PrepareWindowFunctionClauseExp(ECSqlPrepareContext
ctx.GetSqlBuilder().AppendComma();
ctx.GetSqlBuilder().AppendSpace();
}

ctx.GetSqlBuilder().Append(snippet);
isFirstSnippet = false;
}
Expand Down Expand Up @@ -1946,7 +1946,7 @@ ECSqlStatus ECSqlExpPreparer::PrepareWindowFunctionExp(NativeSqlBuilder::List& n
status = PrepareFunctionCallExp(nativeSqlFunctionSnippets, ctx, exp.GetWindowFunctionCallExp()->GetAs<FunctionCallExp>());
if (!status.IsSuccess())
return status;

for (auto snippet : nativeSqlFunctionSnippets)
nativeSqlBuilder.Append(snippet);

Expand All @@ -1963,7 +1963,7 @@ ECSqlStatus ECSqlExpPreparer::PrepareWindowFunctionExp(NativeSqlBuilder::List& n
status = PrepareWindowSpecification(nativeSqlBuilder, ctx, *e);
if (!status.IsSuccess())
return status;

nativeSqlSnippets.push_back(nativeSqlBuilder);
return ECSqlStatus::Success;
}
Expand All @@ -1977,7 +1977,7 @@ ECSqlStatus ECSqlExpPreparer::PrepareWindowFunctionExp(NativeSqlBuilder::List& n
else
{
ctx.Issues().Report(IssueSeverity::Error, IssueCategory::BusinessProperties, IssueType::ECSQL, ECDbIssueId::ECDb_0661, "Unsupported window function expression.");
return ECSqlStatus::InvalidECSql;
return ECSqlStatus::InvalidECSql;
}
}

Expand Down Expand Up @@ -2070,7 +2070,7 @@ ECSqlStatus ECSqlExpPreparer::PrepareWindowPartitionColumnReferenceList(NativeSq
status = PrepareWindowPartitionColumnReference(nativeSqlBuilder, ctx, exp.GetChildren()[nPos]->GetAs<WindowPartitionColumnReferenceExp>());
if (!status.IsSuccess())
return status;

isFirstItem = false;
}
return ECSqlStatus::Success;
Expand All @@ -2097,7 +2097,7 @@ ECSqlStatus ECSqlExpPreparer::PrepareWindowSpecification(NativeSqlBuilder& nativ

status = PrepareWindowPartitionColumnReferenceList(nativeSqlBuilder, ctx, *e);
if (!status.IsSuccess())
return status;
return status;

isFirstWindowSpecificationClause = false;
}
Expand All @@ -2113,7 +2113,7 @@ ECSqlStatus ECSqlExpPreparer::PrepareWindowSpecification(NativeSqlBuilder& nativ

isFirstWindowSpecificationClause = false;
}

if (WindowFrameClauseExp const * e = exp.GetWindowFrameClause())
{
if (!isFirstWindowSpecificationClause)
Expand All @@ -2123,7 +2123,7 @@ ECSqlStatus ECSqlExpPreparer::PrepareWindowSpecification(NativeSqlBuilder& nativ
if (!status.IsSuccess())
return status;
}

nativeSqlBuilder.AppendParenRight();
return ECSqlStatus::Success;
}
Expand Down Expand Up @@ -2228,10 +2228,10 @@ ECSqlStatus ECSqlExpPreparer::PrepareWindowFrameStartExp(NativeSqlBuilder& nativ
ECSqlStatus status = PrepareValueExp(nativeSqlSnippets, ctx, *exp.GetValueExp());
if (!status.IsSuccess())
return status;

for (const auto& snippet: nativeSqlSnippets)
nativeSqlBuilder.Append(snippet);

nativeSqlBuilder.Append(" PRECEDING");
return ECSqlStatus::Success;
}
Expand Down Expand Up @@ -2358,10 +2358,10 @@ ECSqlStatus ECSqlExpPreparer::PrepareWindowFrameExclusion(NativeSqlBuilder& nati
return ECSqlStatus::Success;
case WindowFrameClauseExp::WindowFrameExclusionType::ExcludeGroup:
nativeSqlBuilder.Append(" EXCLUDE GROUP");
return ECSqlStatus::Success;
return ECSqlStatus::Success;
case WindowFrameClauseExp::WindowFrameExclusionType::ExcludeNoOthers:
nativeSqlBuilder.Append(" EXCLUDE NO OTHERS");
return ECSqlStatus::Success;
return ECSqlStatus::Success;
case WindowFrameClauseExp::WindowFrameExclusionType::ExcludeTies:
nativeSqlBuilder.Append(" EXCLUDE CURRENT ROW");
return ECSqlStatus::Success;
Expand Down Expand Up @@ -2390,7 +2390,7 @@ unsigned int ECSqlExpPreparer::QueryOptionsInstanceFlags(ExpCR exp)
const auto useJsPropName = OptionsExp::FindLocalOrInheritedOption<bool>(exp, OptionsExp::USE_JS_PROP_NAMES, [](OptionExp const& opt) { return opt.asBool(); }, []() { return false; });
const auto doNotTruncateBlob = OptionsExp::FindLocalOrInheritedOption<bool>(exp, OptionsExp::DO_NOT_TRUNCATE_BLOB, [](OptionExp const& opt) { return opt.asBool(); }, []() { return false; });
unsigned int flags = 0;
if (useJsPropName) flags |= InstanceReader::FLAGS_UseJsPropertyNames;
if (useJsPropName) flags |= InstanceReader::FLAGS_UseJsPropertyNames | InstanceReader::FLAGS_ClassIdsToClassNames;
if (doNotTruncateBlob) flags |= InstanceReader::FLAGS_DoNotTruncateBlobs;
return flags;
}
Expand Down Expand Up @@ -2740,7 +2740,7 @@ ECSqlStatus ECSqlExpPreparer::PrepareNavValueCreationFuncExp(NativeSqlBuilder::L
relECClassIdNativeSql.push_back(NativeSqlBuilder (std::to_string(property->GetAsNavigationProperty()->GetRelationshipClass()->GetId().GetValue())));
else
stat = PrepareValueExp(relECClassIdNativeSql, ctx, *exp.GetRelECClassIdExp());

if (!stat.IsSuccess())
return stat;

Expand Down
4 changes: 2 additions & 2 deletions iModelCore/ECDb/ECDb/ECSqlRowAdaptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ BentleyStatus ECSqlRowAdaptor::RenderLong(BeJsValue out, IECSqlValue const& in,
out = id.ToHexStr();
return SUCCESS;
}
if (m_options.m_classIdToClassNames || m_options.m_useJsName) {
if (m_options.m_classIdToClassNames) {
auto classCP = m_ecdb.Schemas().GetClass(id, in.GetColumnInfo().GetRootClass().GetTableSpace().c_str());
if (classCP != nullptr) {
ECN::ECJsonUtilities::ClassNameToJson(out, *classCP);
Expand Down Expand Up @@ -307,7 +307,7 @@ BentleyStatus ECSqlRowAdaptor::RenderNavigationProperty(BeJsValue out, IECSqlVal
auto const& relClassIdVal = in[ECDBSYS_PROP_NavPropRelECClassId];
if (!relClassIdVal.IsNull()) {
const auto classId = relClassIdVal.GetId<ECN::ECClassId>();
if (m_options.m_classIdToClassNames || m_options.m_useJsName) {
if (m_options.m_classIdToClassNames) {
auto classCP = m_ecdb.Schemas().GetClass(classId, in.GetColumnInfo().GetRootClass().GetTableSpace().c_str());
if (classCP != nullptr) {
ECN::ECJsonUtilities::ClassNameToJson(out[jsClassId], *classCP);
Expand Down
1 change: 1 addition & 0 deletions iModelCore/ECDb/PublicAPI/ECDb/InstanceReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ struct InstanceReader final {
public:
constexpr static unsigned FLAGS_UseJsPropertyNames = 0x1u;
constexpr static unsigned FLAGS_DoNotTruncateBlobs = 0x2u;
constexpr static unsigned FLAGS_ClassIdsToClassNames = 0x4u;

struct JsonParams {
private:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ describe("ECSqlStatement", () => {
const meta = stmt.getMetadata();
const row = formatCurrentRow(resp.data, meta.meta, args.useJsName);
assert.equal(row.id, id);
assert.equal(row.className, "Test.Foo");
assert.equal(row.className, "0x58");
assert.equal(row.b0, boolVal);
}

Expand Down
Loading