Giter VIP home page Giter VIP logo

Comments (6)

etagwerker avatar etagwerker commented on August 22, 2024

@graaff It's a good point.

We have a method to check for row count. If that doesn't work we use AUTO_INCREMENT. See: https://github.com/DatabaseCleaner/database_cleaner/blob/master/lib/database_cleaner/active_record/truncation.rb#L70

In the scenario that you're describing, row_count is returning 0?

from database_cleaner-active_record.

graaff avatar graaff commented on August 22, 2024

I see now that I forgot to mention that I am using the :deletion strategy. There the SelectiveTruncation method uses the information_schema to determine row_count. The row_count method in truncation.rb looks like it should work since it uses plain SQL, rather than internal MySQL information.

from database_cleaner-active_record.

carsonreinke avatar carsonreinke commented on August 22, 2024

Also, it should be noted that MySQL states that table_rows: "For InnoDB tables, the row count is only a rough estimate used in SQL optimization." [http://dev.mysql.com/doc/refman/5.5/en/tables-table.html]

from database_cleaner-active_record.

etagwerker avatar etagwerker commented on August 22, 2024

@graaff Would you mind submitting a PR for this? It'd be great if we can use the same way to calculate row_count for both deletion and truncation strategies. I don't understand why they're different right now.

from database_cleaner-active_record.

lupine avatar lupine commented on August 22, 2024

I've just experienced this issue while porting GitLab's spec suite from the truncation strategy to the deletion strategy: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/16516#note_55605767

If there's still interest in a PR to fix this upstream, I'm happy to work on it so we can remove the above monkey-patch!

from database_cleaner-active_record.

mauro-oto avatar mauro-oto commented on August 22, 2024

@lupine awesome, yes, we're interested. Thanks!

from database_cleaner-active_record.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.