-
-
Notifications
You must be signed in to change notification settings - Fork 241
Merge putDtype and putType; remove duplicated code #8610
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
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you not choose better names for methods you created to not duplicate code, I prefer to have the code duplicated.
I understand nothing what the refactored methods do by their names.
src/dsql/DsqlCompilerScratch.cpp
Outdated
putType(*type, useSubType, type->collate.object.hasData()); | ||
} | ||
|
||
void DsqlCompilerScratch::putType(const TypeClause& type, bool useSubType, bool useExplicitCollate) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's weird that the two methods with the same name one expects the type as a pointer and the other as reference.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a design issue. A pointer means that the value can be null, and the method should check for that. But these methods explicitly treat values as non_null. It would have been better to change the original putType and putDType to use references, but I avoided this to avoid changing too many files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd make the reference-based putType()
private to avoid confusion.
And maybe rename putDtype()
to putFieldType()
or make it a putType()
overload with the dsql_fld*
argument. Less than a dozen lines changed, I guess.
I tried to follow the style of the original method names. |
src/dsql/DsqlCompilerScratch.cpp
Outdated
putType(*type, useSubType, type->collate.object.hasData()); | ||
} | ||
|
||
void DsqlCompilerScratch::putType(const TypeClause& type, bool useSubType, bool useExplicitCollate) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd make the reference-based putType()
private to avoid confusion.
And maybe rename putDtype()
to putFieldType()
or make it a putType()
overload with the dsql_fld*
argument. Less than a dozen lines changed, I guess.
src/dsql/DsqlCompilerScratch.cpp
Outdated
putDTypeBlr(type, useSubType); | ||
} | ||
|
||
void DsqlCompilerScratch::putDTypeBlr(const TypeClause& type, const bool useSubType) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAIU, this method is used just once. Does it exist just to reduce the number of lines inside putType()
? Anyway, it should be private, IMHO.
And if putDtype()
above is renamed, then I'd suggest to remove the Blr
suffix here (see the reason in the comment below).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I renamed the putDtype to putType as you suggested
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it exist just to reduce the number of lines inside
putType()
Initially, I took out only this method from putType and putDType, but then I thought that this was a half-measure and it was necessary to do a full-fledged refactoring.
For now I've left this function separate, as I hope in the future it will make it easier to refactor and use a single function to generate TypeClause
and dsc
blr
putFieldType(type, useSubType); | ||
} | ||
|
||
void DsqlCompilerScratch::putFieldType(const TypeClause& type, const bool useSubType) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggested to rename this function to putDType()
after the original putDtype()
was made an overloaded putType()
. The reason is simple - it doesn't care about fields, it only generates BLR for the given data type.
template<bool THasTableName> | ||
void putFieldName(const TypeClause& type, const bool useExplicitCollate); | ||
|
||
void putFieldType(const TypeClause& type, const bool useSubType); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The naming looks confusing - we pass TypeClause
(not dsql_fld
) but they're named putField*
.
What's wrong with putType()
(private overload) / putTypeName()
/ putDType()
?
This is also a preparation for the JSON Type implementation