Click here to Skip to main content
15,881,139 members
Articles / Desktop Programming / Windows Forms

SQLite Compare Utility

Rate me:
Please Sign up or sign in to vote.
4.89/5 (68 votes)
21 Feb 2015LGPL35 min read 280.1K   37.1K   131  
Utility for comparing two SQLite database files for both structure and data
using System;
using System.Collections.Generic;
using System.Text;

namespace SQLiteParser
{
    public class SQLiteNullColumnConstraint : SQLiteColumnConstraint
    {
        private SQLiteNullColumnConstraint(string name)
            : base(name)
        {
        }

        public SQLiteNullColumnConstraint(string name, bool isnull, SQLiteResolveAction conf)
            : base(name)
        {
            _isnull = isnull;
            _conf = conf;
        }

        public bool IsNull
        {
            get { return _isnull; }
            set { _isnull = value; }
        }

        public SQLiteResolveAction ResolveAction
        {
            get { return _conf; }
            set { _conf = value; }
        }

        public override bool Equals(object obj)
        {
            if (obj == null)
                return false;

            SQLiteNullColumnConstraint dst = obj as SQLiteNullColumnConstraint;
            if (dst == null)
                return false;

            if (dst._isnull != this._isnull)
                return false;
            if (this._conf != dst._conf)
                return false;

            return base.Equals(obj);
        }

        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();
            if (ConstraintName != null)
                sb.Append("CONSTRAINT " + ConstraintName + " ");
            if (_isnull)
                sb.Append("NULL");
            else
                sb.Append("NOT NULL");
            if (_conf != SQLiteResolveAction.None)
                sb.Append(" " + Utils.GetConflictClauseString(_conf));
            return sb.ToString();
        }

        public override object Clone()
        {
            SQLiteNullColumnConstraint res = new SQLiteNullColumnConstraint(this.ConstraintName);
            res._isnull = _isnull;
            res._conf = _conf;
            return res;
        }

        private bool _isnull;
        private SQLiteResolveAction _conf;
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The GNU Lesser General Public License (LGPLv3)


Written By
Software Developer
Israel Israel
My name is Liron Levi and I'm developing software for fun & profit for 15 years already.

Comments and Discussions