Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9219759
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T03:11:21+00:00 2026-06-18T03:11:21+00:00

I recently modified my Django project’s settings to that it uses SQLite3 when I

  • 0

I recently modified my Django project’s settings to that it uses SQLite3 when I run tests instead of PostgreSQL so that my tests will run faster. However, once I did that, one of my negative unit tests that checks to verify that Django will throw an error if I try to create a user whose username exceeds 30 characters started failing. Up until this time, the test had always passed.

If I run the following test using PostgreSQL, an exception (specifically a DatabaseError) is raised and the test passes. However, if I use SQLite3 instead, no exception is raised and the test fails. I double-checked the SQLite3 auth_user schema and confirmed username is a varchar(30) field. Has anyone else experienced this? Thanks.

from django.test import TestCase
from django.contrib.auth.models import User

class SimpleTest(TestCase):
    def test_simple(self):
        exception_raised = True  # Exception should be raised since username > 30 chars
        try:
            user = User.objects.create_user(username='testusertestusertestusertestuser')
        except Exception as e:
            exception_raised = False
        assert not exception_raised, "Exception wasn't raised"
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T03:11:23+00:00Added an answer on June 18, 2026 at 3:11 am

    I believe that the reason for this is that sqlite3 converts all varchar data types to the text data type under the hood. This is why the DBMS won’t catch any values that exceed your limit. The documentation is a little bit unclear in this regard, but I ran into this problem before and from the documentation, that was the best answer I could come up with. So basically,

    CREATE TABLE A(name varchar(30))
    

    Will end up being identical to:

    CREATE TABLE A(name text)
    

    Check out the documentation here (section 2.2): http://www.sqlite.org/datatype3.html

    A test you can do to see that this is just the functionality of the DBMS:

    sqlite> create table A(name varchar(2));
    sqlite> insert into A values("hello world");
    sqlite> select * from A;
    hello world
    

    As you can see, there are no errors, and no truncation.

    Hope that helps,

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing a script that gets the most recently modified file from a unix
I recently found this post . It basically says that Eclipse has a modified
I was running my project and was checking recently modified module. On click of
I have an exe containing Fortran and C++ code that was recently modified to
A plugin I installed recently (Aptana Studio) modified all sorts of preference settings, and
I recently modified some old UI code using Delphi's VCL to use ADO instead
I have a file that's been modified recently. Rather than looking into each revision,
I recently had to work on a project where the previous developer modified the
I recently modified a MYSQL query using the keyword RLIKE however when I ran
Recently I have modified my code to While taking input form STDIN, I moved

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.