瀏覽代碼

HUE-8343 [editor] Fix boolean variables

jdesjean 7 年之前
父節點
當前提交
5dc50917f8

+ 8 - 0
desktop/core/src/desktop/templates/common_notebook_ko_components.mako

@@ -725,6 +725,14 @@ except ImportError, e:
                       readOnly: true
                     }}}" class="margin-top-10 margin-bottom-20"></div>
                 </li>
+                <span>${ _('For values that are not textual, omit the quotes.')}</span>
+                <div data-bind="component: { name: 'hue-simple-ace-editor-multi', params: {
+                    value: ko.observable('${ _('select * from boolean_table where boolean_column = ${boolean_column}')}'),
+                    lines: 1,
+                    mode: 'impala',
+                    aceOptions: {
+                      readOnly: true
+                    }}}" class="margin-top-10 margin-bottom-20"></div>
               </ul>
             </div>
           </div>

+ 1 - 1
desktop/libs/notebook/src/notebook/static/notebook/js/notebook.ko.js

@@ -870,7 +870,7 @@ var EditorViewModel = (function() {
           var variable = variables[p2];
           var pad = variable.type() == 'datetime-local' && variable.value().length == 16 ? ':00' : ''; // Chrome drops the seconds from the timestamp when it's at 0 second.
           var value = variable.value();
-          return p1 + (value || value === 0 ? value + pad : variable.meta.placeholder && variable.meta.placeholder());
+          return p1 + (value !== undefined && value !== null ? value + pad : variable.meta.placeholder && variable.meta.placeholder());
         });
       }
       return statement;

+ 5 - 2
desktop/libs/notebook/src/notebook/templates/editor_components.mako

@@ -1250,8 +1250,11 @@ ${ sqlSyntaxDropdown.sqlSyntaxDropdown() }
               <!-- ko if: type() == 'date' -->
               <input class="input-medium" type="text" data-bind="value: value, datepicker: { momentFormat: 'YYYY-MM-DD' }">
               <!-- /ko -->
-              <!-- ko ifnot: (type() == 'datetime-local' || type() == 'date') -->
-              <input class="input-medium" type="text" data-bind="value: value, attr: { type: type() || 'text', step: step }, valueUpdate: 'afterkeydown', event: { 'keydown': $parent.onKeydownInVariable }, autogrowInput: { minWidth: 150, maxWidth: 270, comfortZone: 15 }">
+              <!-- ko if: type() == 'checkbox' -->
+              <input class="input-medium" type="checkbox" data-bind="checked: value">
+              <!-- /ko -->
+              <!-- ko ifnot: (type() == 'datetime-local' || type() == 'date' || type() == 'checkbox') -->
+              <input class="input-medium" type="text" value="true" data-bind="value: value, attr: { type: type() || 'text', step: step }, valueUpdate: 'afterkeydown', event: { 'keydown': $parent.onKeydownInVariable }, autogrowInput: { minWidth: 150, maxWidth: 270, comfortZone: 15 }">
               <!-- /ko -->
             <!-- /ko -->
           <!-- /ko -->

+ 4 - 1
docs/user-guide/user-guide.md

@@ -405,7 +405,10 @@ In addition, the displayed text for multi valued variables can be changed.
 <pre>
 select * from web_logs where country_code = "${country_code=CA(Canada), FR(France), US(United States)}"
 </pre>
-
+For values that are not textual, omit the quotes.
+<pre>
+select * from boolean_table where boolean_column = ${boolean_column}
+</pre>
 ### Syntax checker
 
 A little red underline will display the incorrect syntax so that the query can be fixed before submitting. A right click offers suggestions.