How to use _get_key_unless_is_function method in autotest

Best Python code snippet using autotest_python

models.py

Source:models.py Github

copy

Full Screen

2from django.utils import datastructures3from autotest_lib.frontend.afe import model_logic, readonly_connection4class TempManager(model_logic.ExtendedManager):5 _GROUP_COUNT_NAME = 'group_count'6 def _get_key_unless_is_function(self, field):7 if '(' in field:8 return field9 return self.get_key_on_this_table(field)10 def _get_field_names(self, fields, extra_select_fields={}):11 field_names = []12 for field in fields:13 if field in extra_select_fields:14 field_names.append(field)15 else:16 field_names.append(self._get_key_unless_is_function(field))17 return field_names18 def _get_group_query_sql(self, query, group_by, extra_select_fields):19 group_fields = self._get_field_names(group_by, extra_select_fields)20 select_fields = [field for field in group_fields21 if field not in extra_select_fields]22 for field_name, field_sql in extra_select_fields.iteritems():23 field_sql = self._get_key_unless_is_function(field_sql)24 select_fields.append(field_sql + ' AS ' + field_name)25 # add the extra fields to the query selects, so they'll be sortable26 # and Django won't mess with any of them27 query._select[field_name] = field_sql28 _, where, params = query._get_sql_clause()29 # insert GROUP BY clause into query30 group_by_clause = ' GROUP BY ' + ', '.join(group_fields)31 group_by_position = where.rfind('ORDER BY')32 if group_by_position == -1:33 group_by_position = len(where)34 where = (where[:group_by_position] +35 group_by_clause + ' ' +36 where[group_by_position:])37 return ('SELECT ' + ', '.join(select_fields) + where), params...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run autotest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful