rails in the use of dirty data

2009-05-08  来源:本站原创  分类:Ruby  人气:253 

At the opening of the dirty data (dirty objects), the writer sometimes does not pass a number of changes to the database are not kept inside.

Such as the following code:

self.org_common_flag[COMMON_FLAGS[:agent_flag]]= self.agent_flag ? "0" : "1"

In fact it has already amended the string of a character, but through the writer because they do not call, dirty mark or not changed. Show:

Quote

>> U.org_common_flag_changed?
=> False

Plus a mandatory must want will_change!, Would have modified signs.

self.org_common_flag_will_change!
self.org_common_flag[COMMON_FLAGS[:agent_flag]]= self.agent_flag ? "0" : "1"

Look:

Quote

>> U.org_common_flag_changed?
=> True

Dirty data to reduce a large number of unrelated data update, it also brings some inconvenience, which requires a better test coverage.
Note the use of debugging time _changed?, _change Way to check whether the trigger dirty data. And observe the log in the sql output and check the database content.

相关文章
  • rails in the use of dirty data 2009-05-08

    At the opening of the dirty data (dirty objects), the writer sometimes does not pass a number of changes to the database are not kept inside. Such as the following code: self.org_common_flag[COMMON_FLAGS[:agent_flag]]= self.agent_flag ? "0" : &q

  • Loss of changes. Unrepeatable read. Read dirty data. Mirage Reading 2011-01-14

    2.2 SQL Server 2000 + ADO.NET concurrency control http://apps.hi.baidu.com/share/detail/4855358 2.2.1 Concurrent Coherence Common concurrency concurrent consistency problems include: loss of changes, not repeatable read, read dirty data, Mirage read

  • Loss of changes. Unrepeatable read read dirty data. Phantom read 2011-01-14

    2.2 SQL Server 2000 + ADO.NET concurrency control http://apps.hi.baidu.com/share/detail/4855358 2.2.1 The consistency problem of concurrent Common concurrency concurrent consistency problems include: loss of modification, non-repeatable read, read di

  • Rails in the centralized management of data dictionary approach 2009-05-01

    First create a data dictionary of the model ruby script/generate model dictionary Create_dictionaries then add at the table dictionary definitions: def self.up create_table dictionaries do |t| t.string :category # Classification, distinguishing diffe

  • rails migrate impact of foreign key data 2010-09-19

    require "migration_helpers"class AddToPostUserForeignKey < ActiveRecord::Migration extend MigrationHelpers def self.up add_foreign_key(:posts, :user_id, :users) end def self.down remove_foreign_key(:posts, :user_id) endend

  • About hibernate in one-to-many cascading update data generated dirty solution 2010-04-26

    Have encountered this problem before the fact. I was more than one first delete the data. Further update of one side. Otherwise, the database will produce dirty. Such as teacher.getStudentSet().clear(); Set newStudentSet = new HashSet(); // Will new

  • rails version of the change (1) - rails of the introduction 2009-03-09

    Rails framework are at the first time in July 2004, its R & D is the 26-year-old Danes David Heinemeier Hansson. Different from complex Web development framework, Rails is more in line with actual needs and more efficient Web development framework. R

  • Hibernate data retention 2009-04-19

    Hibernate data retention - Session. Save Ways Session.save user entity objects to the database persistence operations. In other words, Session.save method call with the entity object by matching Insert SQL, data insert database table. Ways Session.sa

  • Dirty, dirty read, non-repeatable read, read hallucination 2010-03-29

    What is a dirty, dirty read, non-repeatable read, hallucinations read? The following terminology is commonly found in the database articles and papers. The operating system is also involved in the analysis. Dirty read means that when a transaction is

  • hibernate operation of the principle of data retention 2009-06-15

    Data, save, update and delete: 1, Session.save () method: Session.save () method is used to save the entity object persistence, that is when the implementation of the session.save () method will generate the corresponding insert SQL statement, the co

  • rails commonly used plug-in 2010-02-21

    From: http://saberma.github.com/2009/09/14/rails-plugin.html Rails plug-ins is very rich, and most of all on github, is very convenient here briefly revise the Rails plug-ins I used Related entities restful_authentication [Essential] generate user en

  • Data table design principles 2010-03-21

    1) should not be for the entire system database design, but should be based on system architecture of the components division, for each component of the operations handled by the database design component units; between different components of the co

  • Hibernate data interception and event listeners 2010-04-17

    Interceptor (Interceptor) org.hibernate.Interceptor interface defines the Hibernate interceptor mechanism to create a General Session object, all the Session object or the Session object persistence operation of all the action will be the designated

  • extjs issue submitted to the rails when the forgery_protection 2010-05-25

    rails in the form has a hidden field forgery_protection_token, when presented in the use of rails also need to submit this data So Ext.BLANK_IMAGE_URL =... back plus a parameter, each time a submission has been transmitted to the parameters Ext.BLANK

  • Services - dirty read. Can not duplicate the time. Virtual Reading 2010-05-27

    Dirty read dirty reads: When the transaction has not yet been submitted to read data, such incidents occur. For example: Transaction 1 changes a row, then Transaction 2 modification in Transaction 1 has not yet submitted before the operation had been

  • The difference between database and data warehouse [change] 2010-05-30

    [Size = medium] In short, transaction-oriented database design, data warehouse is subject-oriented design. General store online transaction database data, data warehouse is generally stored historical data. Database design is to avoid redundancy, the

  • Oracle client handling the data row locking problem (select for update) 2010-07-07

    Data integrity and concurrency: Process the data in the network database, it is necessary to ensure data integrity, multi-transaction concurrency and data consistency. Database system must guarantee the maximum data content is effective and reasonabl

  • Some things array.map rails clutter Rails application to initiate block operation 2010-07-19

    Array.map Usage Today, looking beast in the source code, in time to see topics_controller # show found a line can not read the code: @ Voices = @ posts.map (&: user); Then looked at the doc, the doc found no explanation on the usage, then google, but

  • rails of some messy things array.map Rails application to initiate block operation 2010-07-19

    Array.map Usage Today, looking beast in the source code, in time to see topics_controller # show found a line can not read the code: @ Voices = @ posts.map (&: user); Then looked at the doc, the doc found no explanation on the usage, then google, but

  • [Fashionista] What is the dirty, dirty read, unrepeatable read, hallucinations Reading 2010-08-10

    The following terminology is common in database articles, papers. Analysis of the operating system is also involved. Dirty read means that when a transaction is accessing data, and the data was modified, and this modification has not yet committed in