question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

DEFAULTED_ON_CREATE not supported in alternate testing DB?

See original GitHub issue

Hi! I’ve successfully set up an alternate testing DB with SQLite as instructed in the readme, however when running my tests, I get the following error:

django.db.utils.InterfaceError: Error binding parameter 1 - probably unsupported type

This appears to come from a field I have defined as:

is_active = models.BooleanField(custom=True,
                                db_column='Is_Active__c', 
                                default=models.DEFAULTED_ON_CREATE)

A quick look at the execute method in django/db/backends/sqlite3/base.py reveals that the Is_Active__c param that django is trying to save is: <salesforce.backend.operations.DefaultedOnCreate object at 0x10f233c50> … instead of True/False. Changing that param value to either True or False while debugging does indeed solve the problem.

Is there a known issue working with DEFAULTED_ON_CREATE in alternate DBs? Am I missing some kind of configuration?

Thanks!

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
hynekcercommented, Apr 28, 2020

Most problems are already solved by the PR for version 1.0.

Instead of your proposal testing_default a parameter for DefaultedOnCreate() is implemented, e.g.:

from django.utils.timezone import now

class ...:
    is_active = models.BooleanField(default=models.DefaultedOnCreate(True))
    created_date = models.DateTimeField(default=models.DefaultedOnCreate(now),
                                        sf_read_only=models.READ_ONLY)

A documentation for it is in wiki Introspection and Special Attributes of Fields.

Missing part: tests (a new test project that runs on Salesforce then on ‘default’ and possibly also with and without migrations)

0reactions
hynekcercommented, Jun 19, 2019

The right solution should be simpler then A), B) or your code.

The algorithm of inspectdb command was stable long time and it ignored default values that were useful only with non-Salesforce databases.

I wrote a patch for inspectdb

  • Support for introspection with DefaultedOnCreate(value). 6aab51bc

to export more information, e.g.

    default=models.DefaultedOnCreate(False)`,
    default=models.DefaultedOnCreate('NotSeen'), choices=[('NotSeen', 'Not Seen'), ...],

Nothing is changed in the backend implementation yet, but you can still simplify your code by:

class TestableBooleanField(models.BooleanField):
    def __init__(self, **kwargs):
        if settings.ENV == 'test' and isinstance(kwargs['default']), DefaultedOnCreate):
            kwargs['default'] = kwargs['default'].arg
        super(TestableBooleanField, self).__init__(default=default, **kwargs)

(not fixed, but a progress)

  • A problem is also in Salesforce with objects that were just created if they are saved once more without previous refreshing fields that were assigned by Salesforce defaults. We can try a special request that writes some fields and reads some fields in the same request. Useful for those fields with sf_read_only attribute (e.g. a formula that depends on ohter fields) or with DefaultedOnCreate

  • No field on the Salesforce platform expects a default value from the application.

Read more comments on GitHub >

github_iconTop Results From Across the Web

django-salesforce - PyPI
Note that Django 1.4.x is not compatible with Python 3. ... Migrations - Migrations can be used for an alternate test database with...
Read more >
California Assessment Accessibility Resources Matrix
Part 4—Instructional Supports and Resources for the Alternate Assessments ... A student is not permitted to use keyboarding assistance in the test.
Read more >
Alternate ACCESS for ELLs - WIDA
Alternate ACCESS for ELLs (Alternate ACCESS) is a large-print, paper-based test individually administered to students in grades 1-12 who are identified as ...
Read more >
Hawaii State Alternate Assessments - HSA-Alt - alohahsap.org
The HSA-Alt Interim Assessments are not mandatory assessments. ... designated support, Translated Test may be set in TIDE by the Test.
Read more >
2022-2023 NSCAS Not Tested Codes (NTC)
Alternate Assessment. Student took the NSCAS Alternate assessment and is not included in results from this testing vendor. ADVISER data must support coding....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found