コード例 #1
0
 def get_pg_sql_insert_clause(self, document_language: str,
                              python_values: List) -> SQLInsertClause:
     money = first_or_none(python_values) or self.default_value  # Dict
     currency = money.get('currency') if money else None
     amount = money.get('amount') if money else None
     return SQLInsertClause(
         '"{currency_column}", '
         '"{amount_column}"'.format(currency_column=self.currency_column,
                                    amount_column=self.amount_column), [],
         '%s, %s', [currency, amount])
コード例 #2
0
 def python_values_to_single_db_value(self, python_values: List) -> Any:
     python_value = first_or_none(python_values) or self.default_value
     return bool(python_value) if python_value is not None else False
コード例 #3
0
 def python_values_to_single_db_value(self, python_values: List) -> Any:
     address = first_or_none(python_values) or self.default_value  # Dict
     return str(address.get('address') or '') if address else None
コード例 #4
0
 def python_values_to_single_db_value(self, python_values: List) -> Any:
     python_value = first_or_none(python_values) or self.default_value
     return python_value if type(python_value) is date \
         else python_value.date() if type(python_value) is datetime \
         else None
コード例 #5
0
 def python_values_to_single_db_value(self, python_values: List) -> Any:
     python_value = first_or_none(python_values) or self.default_value
     return float(python_value) if python_value else None
コード例 #6
0
 def python_values_to_single_db_value(self,
                                      python_values: List) -> Optional[str]:
     return first_or_none(python_values) or self.default_value
コード例 #7
0
 def python_values_to_single_db_value(self, python_values: List) -> Any:
     python_value = first_or_none(python_values)
     return int(python_value) if python_value else None
コード例 #8
0
 def python_values_to_single_db_value_for_text_search(
         self, python_values: List) -> Optional[str]:
     return first_or_none(python_values)