SQLJoin.cpp 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /*##############################################################################
  2. HPCC SYSTEMS software Copyright (C) 2014 HPCC Systems.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. ############################################################################## */
  13. #include "SQLJoin.hpp"
  14. SQLJoinType SQLJoin::defaultType = SQLJoinTypeInner;
  15. SQLJoin::SQLJoin()
  16. {
  17. type = defaultType;
  18. hasOnclause = false;
  19. }
  20. SQLJoin::SQLJoin(SQLJoinType jointype)
  21. {
  22. switch (jointype)
  23. {
  24. case SQLJoinTypeImplicit:
  25. case SQLJoinTypeInner:
  26. case SQLJoinTypeOuter:
  27. type = jointype;
  28. break;
  29. default:
  30. type = defaultType;
  31. break;
  32. }
  33. hasOnclause = false;
  34. }
  35. SQLJoin::~SQLJoin()
  36. {
  37. #ifdef _DEBUG
  38. fprintf(stderr, "Leaving SQLJoin");
  39. #endif
  40. }
  41. void SQLJoin::getSQLTypeStr(StringBuffer & outstr)
  42. {
  43. switch (type)
  44. {
  45. case SQLJoinTypeImplicit:
  46. case SQLJoinTypeInner:
  47. outstr.append(" INNER JOIN ");
  48. break;
  49. case SQLJoinTypeOuter:
  50. outstr.append(" OUTER JOIN ");
  51. break;
  52. default:
  53. outstr.append(" JOIN ");
  54. break;
  55. }
  56. }
  57. void SQLJoin::getECLTypeStr(StringBuffer & outstr)
  58. {
  59. switch (type)
  60. {
  61. case SQLJoinTypeImplicit:
  62. case SQLJoinTypeInner:
  63. outstr.append(" INNER ");
  64. break;
  65. case SQLJoinTypeOuter:
  66. outstr.append(" FULL OUTER ");
  67. break;
  68. default:
  69. outstr.append(" ");
  70. break;
  71. }
  72. }
  73. void SQLJoin::toString(StringBuffer & str)
  74. {
  75. getSQLTypeStr(str);
  76. if (type != SQLJoinTypeImplicit)
  77. {
  78. str.append(" ON ");
  79. onClause->toString(str, true);
  80. }
  81. }